From 6ffef3359dad30970b116160cbd82e50d86f7a14 Mon Sep 17 00:00:00 2001 From: shahargl Date: Wed, 23 Oct 2024 14:59:02 +0300 Subject: [PATCH] fix: migration --- .../versions/2024-10-22-10-38_8438f041ee0e.py | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/keep/api/models/db/migrations/versions/2024-10-22-10-38_8438f041ee0e.py b/keep/api/models/db/migrations/versions/2024-10-22-10-38_8438f041ee0e.py index 2fc6cf1f2..dac33f5aa 100644 --- a/keep/api/models/db/migrations/versions/2024-10-22-10-38_8438f041ee0e.py +++ b/keep/api/models/db/migrations/versions/2024-10-22-10-38_8438f041ee0e.py @@ -40,19 +40,22 @@ def upgrade() -> None: batch_op.alter_column("pulling_enabled", nullable=False) else: # PostgreSQL and other databases implementation - with op.batch_alter_table("provider", schema=None) as batch_op: - # 1. Add the column as nullable - batch_op.add_column( - sa.Column("pulling_enabled", sa.Boolean(), nullable=True) - ) - # 2. Set default value for existing rows - op.execute( - "UPDATE provider SET pulling_enabled = true WHERE pulling_enabled IS NULL" - ) - # 3. Make it non-nullable - batch_op.alter_column( - "pulling_enabled", nullable=False, server_default=sa.true() - ) + # 1. Add the column as nullable + op.add_column( + "provider", sa.Column("pulling_enabled", sa.Boolean(), nullable=True) + ) + # 2. Set default value for existing rows + op.execute( + "UPDATE provider SET pulling_enabled = true WHERE pulling_enabled IS NULL" + ) + # 3. Make it non-nullable with default + op.alter_column( + "provider", + "pulling_enabled", + existing_type=sa.Boolean(), + nullable=False, + server_default=sa.true(), + ) def downgrade() -> None: