in annotation/alembic/versions/89276b8ebe84_remove_annotateddoc_constraint.py [0:0]
def downgrade():
op.execute(
'DELETE FROM annotated_docs WHERE "user" IS NULL AND pipeline IS NULL'
)
op.create_check_constraint(
"annotated_docs_check",
"annotated_docs",
'("user" IS NULL AND pipeline IS NOT NULL) OR '
'("user" IS NOT NULL AND pipeline IS NULL)',
)
op.drop_constraint(
"annotated_docs_user_fkey", "annotated_docs", type_="foreignkey"
)
op.drop_constraint(
"annotated_docs_task_id_fkey", "annotated_docs", type_="foreignkey"
)
op.create_foreign_key(
"annotated_docs_user_fkey",
"annotated_docs",
"users",
["user"],
["user_id"],
)
op.create_foreign_key(
"annotated_docs_task_id_fkey",
"annotated_docs",
"tasks",
["task_id"],
["id"],
ondelete="CASCADE",
)