From def9f1ca5fd5a8520a51387ee35d8bfb88d2060e Mon Sep 17 00:00:00 2001 From: Yuri Chiucconi Date: Mon, 9 Sep 2024 11:27:23 +0200 Subject: [PATCH] avoit drop_constraint in sqlite --- ...2_remove_link_between_v1_and_v2_tasks_.py} | 44 ++++++------------- 1 file changed, 13 insertions(+), 31 deletions(-) rename fractal_server/migrations/versions/{9e081c49e542_remove_link_between_v1_and_v2_tasks_.py => 820d66a50cc2_remove_link_between_v1_and_v2_tasks_.py} (60%) diff --git a/fractal_server/migrations/versions/9e081c49e542_remove_link_between_v1_and_v2_tasks_.py b/fractal_server/migrations/versions/820d66a50cc2_remove_link_between_v1_and_v2_tasks_.py similarity index 60% rename from fractal_server/migrations/versions/9e081c49e542_remove_link_between_v1_and_v2_tasks_.py rename to fractal_server/migrations/versions/820d66a50cc2_remove_link_between_v1_and_v2_tasks_.py index 39f043aea8..39c3b9f494 100644 --- a/fractal_server/migrations/versions/9e081c49e542_remove_link_between_v1_and_v2_tasks_.py +++ b/fractal_server/migrations/versions/820d66a50cc2_remove_link_between_v1_and_v2_tasks_.py @@ -1,56 +1,38 @@ """Remove link between v1 and v2 tasks/workflowtasks tables -Revision ID: 9e081c49e542 +Revision ID: 820d66a50cc2 Revises: 5bf02391cfef -Create Date: 2024-09-04 08:44:12.471028 +Create Date: 2024-09-09 11:21:59.311683 """ import sqlalchemy as sa from alembic import op +from sqlalchemy.dialects import sqlite + # revision identifiers, used by Alembic. -revision = "9e081c49e542" +revision = "820d66a50cc2" down_revision = "5bf02391cfef" branch_labels = None depends_on = None def upgrade() -> None: - - # We modified the auto generated commands because sqlite does not support - # "alter table". They would have worked fine with postgresql. - # ### commands auto generated by Alembic - please adjust! ### - # op.drop_column("task", "is_v2_compatible") - # op.alter_column( - # "workflowtaskv2", - # "task_id", - # existing_type=sa.INTEGER(), - # nullable=False, - # ) - # op.drop_constraint( - # "fk_workflowtaskv2_task_legacy_id_task", - # "workflowtaskv2", - # type_="foreignkey", - # ) - # op.drop_column("workflowtaskv2", "task_legacy_id") - # op.drop_column("workflowtaskv2", "is_legacy_task") - # ### end Alembic commands ### - - with op.batch_alter_table("task", schema=None) as batch_op: - batch_op.drop_column("is_v2_compatible") - - with op.batch_alter_table("workflowtaskv2", schema=None) as batch_op: - batch_op.drop_constraint( - "fk_workflowtaskv2_task_legacy_id_task", type_="foreignkey" - ) - + op.drop_column("task", "is_v2_compatible") with op.batch_alter_table("workflowtaskv2", schema=None) as batch_op: batch_op.alter_column( "task_id", existing_type=sa.INTEGER(), nullable=False ) batch_op.drop_column("task_legacy_id") batch_op.drop_column("is_legacy_task") + if not isinstance(op.get_bind().dialect, sqlite.dialect): + op.drop_constraint( + "fk_workflowtaskv2_task_legacy_id_task", + "workflowtaskv2", + type_="foreignkey", + ) + # ### end Alembic commands ### def downgrade() -> None: