Fix column name check in folder_id column (#1999)
* bug: fix column name check in folder_id column
This commit is contained in:
parent
8f6b9d6443
commit
8250c2a2eb
1 changed files with 4 additions and 2 deletions
|
|
@ -48,7 +48,8 @@ def upgrade() -> None:
|
||||||
with op.batch_alter_table("folder", schema=None) as batch_op:
|
with op.batch_alter_table("folder", schema=None) as batch_op:
|
||||||
batch_op.create_index(batch_op.f("ix_folder_name"), ["name"], unique=False)
|
batch_op.create_index(batch_op.f("ix_folder_name"), ["name"], unique=False)
|
||||||
|
|
||||||
if "folder_id" not in inspector.get_columns("flow"):
|
column_names = [column["name"] for column in inspector.get_columns("flow")]
|
||||||
|
if "folder_id" not in column_names:
|
||||||
with op.batch_alter_table("flow", schema=None) as batch_op:
|
with op.batch_alter_table("flow", schema=None) as batch_op:
|
||||||
batch_op.add_column(sa.Column("folder_id", sqlmodel.sql.sqltypes.GUID(), nullable=True))
|
batch_op.add_column(sa.Column("folder_id", sqlmodel.sql.sqltypes.GUID(), nullable=True))
|
||||||
batch_op.create_foreign_key("flow_folder_id_fkey", "folder", ["folder_id"], ["id"])
|
batch_op.create_foreign_key("flow_folder_id_fkey", "folder", ["folder_id"], ["id"])
|
||||||
|
|
@ -62,7 +63,8 @@ def downgrade() -> None:
|
||||||
inspector = Inspector.from_engine(conn) # type: ignore
|
inspector = Inspector.from_engine(conn) # type: ignore
|
||||||
table_names = inspector.get_table_names()
|
table_names = inspector.get_table_names()
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
if "folder_id" in inspector.get_columns("flow"):
|
column_names = [column["name"] for column in inspector.get_columns("flow")]
|
||||||
|
if "folder_id" in column_names:
|
||||||
with op.batch_alter_table("flow", schema=None) as batch_op:
|
with op.batch_alter_table("flow", schema=None) as batch_op:
|
||||||
batch_op.add_column(sa.Column("folder", sa.VARCHAR(), nullable=True))
|
batch_op.add_column(sa.Column("folder", sa.VARCHAR(), nullable=True))
|
||||||
batch_op.drop_constraint("flow_folder_id_fkey", type_="foreignkey")
|
batch_op.drop_constraint("flow_folder_id_fkey", type_="foreignkey")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue