🗃 — Fix some migrations for SQLite

This commit is contained in:
Luc Didry 2024-04-08 11:21:57 +02:00
parent a9b7b8f750
commit fa4de8a2b7
No known key found for this signature in database
GPG key ID: EA868E12D0257E3C
2 changed files with 9 additions and 3 deletions

View file

@ -18,7 +18,9 @@ depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
bind = op.get_bind()
with op.batch_alter_table("results", schema=None) as batch_op:
if bind.engine.name != "sqlite":
batch_op.drop_constraint("results_task_id_fkey", type_="foreignkey")
batch_op.create_foreign_key(
"results_task_id_fkey", "tasks", ["task_id"], ["id"], ondelete="CASCADE"
@ -26,7 +28,9 @@ def upgrade() -> None:
def downgrade() -> None:
bind = op.get_bind()
with op.batch_alter_table("results", schema=None) as batch_op:
if bind.engine.name != "sqlite":
batch_op.drop_constraint("results_task_id_fkey", type_="foreignkey")
batch_op.create_foreign_key(
"results_task_id_fkey", "tasks", ["task_id"], ["id"]

View file

@ -19,6 +19,8 @@ depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
bind = op.get_bind()
if bind.engine.name != "sqlite":
op.execute("ALTER TYPE severity ADD VALUE 'unknown'")
op.add_column(
"tasks",