🐛 fix(alembic): add exception handling to prevent migration failure if columns already exist
This commit is contained in:
parent
92a109b65c
commit
a65086c8e4
1 changed files with 17 additions and 13 deletions
|
|
@ -21,25 +21,29 @@ depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
def upgrade() -> None:
|
def upgrade() -> None:
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
with op.batch_alter_table("flow", schema=None) as batch_op:
|
try:
|
||||||
batch_op.add_column(sa.Column("is_component", sa.Boolean(), nullable=False))
|
with op.batch_alter_table("flow", schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column("is_component", sa.Boolean(), nullable=False))
|
||||||
|
|
||||||
with op.batch_alter_table("user", schema=None) as batch_op:
|
with op.batch_alter_table("user", schema=None) as batch_op:
|
||||||
batch_op.add_column(
|
batch_op.add_column(
|
||||||
sa.Column(
|
sa.Column(
|
||||||
"store_api_key", sqlmodel.sql.sqltypes.AutoString(), nullable=True
|
"store_api_key", sqlmodel.sql.sqltypes.AutoString(), nullable=True
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as exc:
|
||||||
|
pass
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
def downgrade() -> None:
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
with op.batch_alter_table("user", schema=None) as batch_op:
|
try:
|
||||||
batch_op.drop_column("store_api_key")
|
with op.batch_alter_table("user", schema=None) as batch_op:
|
||||||
|
batch_op.drop_column("store_api_key")
|
||||||
with op.batch_alter_table("flow", schema=None) as batch_op:
|
|
||||||
batch_op.drop_column("is_component")
|
|
||||||
|
|
||||||
|
with op.batch_alter_table("flow", schema=None) as batch_op:
|
||||||
|
batch_op.drop_column("is_component")
|
||||||
|
except Exception as exc:
|
||||||
|
pass
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue