mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-03 03:31:09 +02:00
update foreign key migration
This commit is contained in:
parent
17b280e59e
commit
ffe8ac168f
@ -16,16 +16,18 @@ depends_on = None
|
|||||||
|
|
||||||
|
|
||||||
def upgrade() -> None:
|
def upgrade() -> None:
|
||||||
# First drop the existing FK constraints
|
# Safely drop constraints if exists
|
||||||
op.drop_constraint(
|
op.execute(
|
||||||
"inputprompt__user_input_prompt_id_fkey",
|
"""
|
||||||
"inputprompt__user",
|
ALTER TABLE inputprompt__user
|
||||||
type_="foreignkey",
|
DROP CONSTRAINT IF EXISTS inputprompt__user_input_prompt_id_fkey
|
||||||
|
"""
|
||||||
)
|
)
|
||||||
op.drop_constraint(
|
op.execute(
|
||||||
"inputprompt__user_user_id_fkey",
|
"""
|
||||||
"inputprompt__user",
|
ALTER TABLE inputprompt__user
|
||||||
type_="foreignkey",
|
DROP CONSTRAINT IF EXISTS inputprompt__user_user_id_fkey
|
||||||
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
# Recreate with ON DELETE CASCADE
|
# Recreate with ON DELETE CASCADE
|
||||||
@ -37,10 +39,11 @@ def upgrade() -> None:
|
|||||||
["id"],
|
["id"],
|
||||||
ondelete="CASCADE",
|
ondelete="CASCADE",
|
||||||
)
|
)
|
||||||
|
|
||||||
op.create_foreign_key(
|
op.create_foreign_key(
|
||||||
"inputprompt__user_user_id_fkey",
|
"inputprompt__user_user_id_fkey",
|
||||||
"inputprompt__user",
|
"inputprompt__user",
|
||||||
'"user"',
|
"user",
|
||||||
["user_id"],
|
["user_id"],
|
||||||
["id"],
|
["id"],
|
||||||
ondelete="CASCADE",
|
ondelete="CASCADE",
|
||||||
@ -71,7 +74,7 @@ def downgrade() -> None:
|
|||||||
op.create_foreign_key(
|
op.create_foreign_key(
|
||||||
"inputprompt__user_user_id_fkey",
|
"inputprompt__user_user_id_fkey",
|
||||||
"inputprompt__user",
|
"inputprompt__user",
|
||||||
'"user"',
|
"user",
|
||||||
["user_id"],
|
["user_id"],
|
||||||
["id"],
|
["id"],
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user