Fix "Skipping unsupported ALTER" warning on database migration

This commit is contained in:
Andrew Dickinson 2020-04-25 20:53:10 -04:00
parent e2cd3342d0
commit d5e6370bbe

View file

@ -165,6 +165,18 @@ def upgrade():
sa.Column("remote_addr", sa.String(length=50), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
bind = op.get_bind()
if bind.engine.name == "sqlite":
with op.batch_alter_table("project", recreate="always") as batch_op:
batch_op.add_column(
sa.Column(
"logging_preference",
sa.Enum("DISABLED", "ENABLED", "RECORD_IP", name="loggingmode"),
server_default="ENABLED",
nullable=False,
),
)
else:
op.add_column(
"project",
sa.Column(
@ -179,6 +191,12 @@ def upgrade():
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
bind = op.get_bind()
if bind.engine.name == "sqlite":
with op.batch_alter_table("project", recreate="always") as batch_op:
batch_op.drop_column("logging_preference")
else:
op.drop_column("project", "logging_preference")
op.drop_table("transaction")
op.drop_index(