From a65086c8e44ee51eed11e81114f2eff646ceff66 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 18 Oct 2023 18:18:07 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(alembic):=20add=20exception?= =?UTF-8?q?=20handling=20to=20prevent=20migration=20failure=20if=20columns?= =?UTF-8?q?=20already=20exist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../595c9c2a2ad4_changes_for_the_store.py | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/backend/langflow/alembic/versions/595c9c2a2ad4_changes_for_the_store.py b/src/backend/langflow/alembic/versions/595c9c2a2ad4_changes_for_the_store.py index 69e8b44d6..b856c3bc1 100644 --- a/src/backend/langflow/alembic/versions/595c9c2a2ad4_changes_for_the_store.py +++ b/src/backend/langflow/alembic/versions/595c9c2a2ad4_changes_for_the_store.py @@ -21,25 +21,29 @@ depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table("flow", schema=None) as batch_op: - batch_op.add_column(sa.Column("is_component", sa.Boolean(), nullable=False)) + try: + 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: - batch_op.add_column( - sa.Column( - "store_api_key", sqlmodel.sql.sqltypes.AutoString(), nullable=True + with op.batch_alter_table("user", schema=None) as batch_op: + batch_op.add_column( + sa.Column( + "store_api_key", sqlmodel.sql.sqltypes.AutoString(), nullable=True + ) ) - ) - + except Exception as exc: + pass # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### - 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") + try: + 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") + except Exception as exc: + pass # ### end Alembic commands ###