Skip to content

Instantly share code, notes, and snippets.

@SuryaSankar
Created May 11, 2014 17:12
Show Gist options
  • Save SuryaSankar/95138a59d16054cca757 to your computer and use it in GitHub Desktop.
Save SuryaSankar/95138a59d16054cca757 to your computer and use it in GitHub Desktop.
Alembic migration for modifying a Enum field
from alembic import op
import sqlalchemy as sa
def upgrade():
op.alter_column(table_name='items', column_name='status', nullable=False, server_default="pending_with_moderator", name="status",
type_=sa.types.Enum('pending_with_moderator','pending_with_user','awaiting_user_modification','awaiting_moderator_modification','approved'),
existing_type=sa.types.Enum('pending_with_moderator', 'pending_with_user', 'approved'),existing_server_default="pending_with_moderator",
existing_nullable=False)
def downgrade():
op.alter_column(table_name='items', column_name='status', nullable=False, server_default="pending_with_moderator", name="status",
existing_type=sa.types.Enum('pending_with_moderator','pending_with_user','awaiting_user_modification','awaiting_moderator_modification','approved'),
type_=sa.types.Enum('pending_with_moderator', 'pending_with_user', 'approved'),existing_server_default="pending_with_moderator",
existing_nullable=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment