fix: prevent double enum creation in migrations 019/020 (create_type=False)
This commit is contained in:
parent
ddeaf9ac41
commit
198170d999
2 changed files with 10 additions and 3 deletions
|
|
@ -16,10 +16,14 @@ depends_on = None
|
|||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Create the highlight_status enum type
|
||||
# Create the highlight_status enum type (create_type=False on the column
|
||||
# prevents SQLAlchemy's before_create event from double-creating it)
|
||||
highlight_status = sa.Enum("candidate", "approved", "rejected", name="highlight_status", create_constraint=True)
|
||||
highlight_status.create(op.get_bind(), checkfirst=True)
|
||||
|
||||
# Use create_type=False so create_table doesn't try to recreate the enum
|
||||
hl_col_type = sa.Enum("candidate", "approved", "rejected", name="highlight_status", create_type=False)
|
||||
|
||||
op.create_table(
|
||||
"highlight_candidates",
|
||||
sa.Column("id", UUID(as_uuid=True), primary_key=True, server_default=sa.text("gen_random_uuid()")),
|
||||
|
|
@ -28,7 +32,7 @@ def upgrade() -> None:
|
|||
sa.Column("score", sa.Float, nullable=False),
|
||||
sa.Column("score_breakdown", sa.dialects.postgresql.JSONB, nullable=True),
|
||||
sa.Column("duration_secs", sa.Float, nullable=False),
|
||||
sa.Column("status", highlight_status, nullable=False, server_default="candidate"),
|
||||
sa.Column("status", hl_col_type, nullable=False, server_default="candidate"),
|
||||
sa.Column("created_at", sa.DateTime, server_default=sa.func.now(), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime, server_default=sa.func.now(), nullable=False),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -19,9 +19,12 @@ def upgrade() -> None:
|
|||
chapter_status = sa.Enum("draft", "approved", "hidden", name="chapter_status", create_constraint=True)
|
||||
chapter_status.create(op.get_bind(), checkfirst=True)
|
||||
|
||||
# Use create_type=False to prevent double-creation during add_column
|
||||
ch_col_type = sa.Enum("draft", "approved", "hidden", name="chapter_status", create_type=False)
|
||||
|
||||
op.add_column(
|
||||
"key_moments",
|
||||
sa.Column("chapter_status", chapter_status, nullable=False, server_default="draft"),
|
||||
sa.Column("chapter_status", ch_col_type, nullable=False, server_default="draft"),
|
||||
)
|
||||
op.add_column(
|
||||
"key_moments",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue