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
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
@ -27,14 +28,8 @@ def upgrade() -> None:
inspector = sa.inspect(connection)
if "sync_operations" not in inspector.get_table_names():
# 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",
sa.Enum(
if op.get_context().dialect.name == "postgresql":
syncstatus = postgresql.ENUM(
"STARTED",
"IN_PROGRESS",
"COMPLETED",
@ -42,7 +37,26 @@ def upgrade() -> None:
"CANCELLED",
name="syncstatus",
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,
),
sa.Column("progress_percentage", sa.Integer(), nullable=True),