Skip to content

Commit

Permalink
varchar instead of enum
Browse files Browse the repository at this point in the history
  • Loading branch information
AAfghahi committed Apr 27, 2021
1 parent a9586eb commit 9db249b
Showing 1 changed file with 1 addition and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,17 @@
revision = "d416d0d715cc"
down_revision = "19e978e1b9c3"

from enum import Enum

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
from sqlalchemy.dialects.postgresql.base import PGDialect

limiting_factor = postgresql.ENUM(
"DROPDOWN",
"QUERY",
"NOT_LIMITED",
"QUERY_AND_DROPDOWN",
"UNKNOWN",
name="limitingfactor",
)


def upgrade():
bind = op.get_bind()
if isinstance(bind.dialect, PGDialect):
limiting_factor.create(bind)
with op.batch_alter_table("query") as batch_op:
batch_op.add_column(
sa.Column(
"limiting_factor",
sa.Enum(
"DROPDOWN",
"QUERY",
"NOT_LIMITED",
"QUERY_AND_DROPDOWN",
"UNKNOWN",
name="limitingfactor",
),
server_default="UNKNOWN",
)
sa.Column("limiting_factor", sa.VARCHAR(255), server_default="UNKNOWN",)
)


def downgrade():
with op.batch_alter_table("query") as batch_op:
batch_op.drop_column("limiting_factor")
bind = op.get_bind()
if isinstance(bind.dialect, PGDialect):
limiting_factor.drop(bind)

0 comments on commit 9db249b

Please sign in to comment.