mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-06 08:18:53 +00:00
fix: catch edge case for no pks and check on downgrade
This commit is contained in:
parent
7f7cf8fb29
commit
fcc99d9378
1 changed files with 8 additions and 1 deletions
|
|
@ -33,7 +33,7 @@ def upgrade() -> None:
|
|||
inspector = Inspector.from_engine(conn)
|
||||
|
||||
for table, column in TABLES:
|
||||
pk = inspector.get_pk_constraint(table)
|
||||
pk = inspector.get_pk_constraint(table) or {}
|
||||
if column in (pk.get("constrained_columns") or []):
|
||||
continue
|
||||
|
||||
|
|
@ -46,6 +46,13 @@ def upgrade() -> None:
|
|||
|
||||
|
||||
def downgrade() -> None:
|
||||
conn = op.get_bind()
|
||||
inspector = Inspector.from_engine(conn)
|
||||
|
||||
for table, column in TABLES:
|
||||
pk = inspector.get_pk_constraint(table) or {}
|
||||
if column not in (pk.get("constrained_columns") or []):
|
||||
continue
|
||||
|
||||
with op.batch_alter_table(table, schema=None) as batch_op:
|
||||
batch_op.drop_constraint(f"pk_{column}", type_="primary")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue