fix: Resolve issue with sync migration not working for postgresql

This commit is contained in:
Igor Ilic 2025-11-05 16:05:33 +01:00
parent 9fc4199958
commit fa4c50f972

View file

@ -10,6 +10,7 @@ from typing import Sequence, Union
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
@ -27,14 +28,8 @@ def upgrade() -> None:
inspector = sa.inspect(connection) inspector = sa.inspect(connection)
if "sync_operations" not in inspector.get_table_names(): if "sync_operations" not in inspector.get_table_names():
# Table doesn't exist, create it normally if op.get_context().dialect.name == "postgresql":
op.create_table( syncstatus = postgresql.ENUM(
"sync_operations",
sa.Column("id", sa.UUID(), nullable=False),
sa.Column("run_id", sa.Text(), nullable=True),
sa.Column(
"status",
sa.Enum(
"STARTED", "STARTED",
"IN_PROGRESS", "IN_PROGRESS",
"COMPLETED", "COMPLETED",
@ -42,7 +37,26 @@ def upgrade() -> None:
"CANCELLED", "CANCELLED",
name="syncstatus", name="syncstatus",
create_type=False, create_type=False,
), )
else:
syncstatus = sa.Enum(
"STARTED",
"IN_PROGRESS",
"COMPLETED",
"FAILED",
"CANCELLED",
name="syncstatus",
create_type=False,
)
# Table doesn't exist, create it normally
op.create_table(
"sync_operations",
sa.Column("id", sa.UUID(), nullable=False),
sa.Column("run_id", sa.Text(), nullable=True),
sa.Column(
"status",
syncstatus,
nullable=True, nullable=True,
), ),
sa.Column("progress_percentage", sa.Integer(), nullable=True), sa.Column("progress_percentage", sa.Integer(), nullable=True),