diff --git a/migrations/versions/0001_initial_schema.py b/migrations/versions/0001_initial_schema.py index 04886db..0f4ec00 100644 --- a/migrations/versions/0001_initial_schema.py +++ b/migrations/versions/0001_initial_schema.py @@ -44,6 +44,11 @@ def _timestamps() -> list[sa.Column]: ] +# create_type=False on every enum below: their CREATE TYPE / DROP TYPE DDL +# is issued explicitly in upgrade()/downgrade() instead. Without this, +# SQLAlchemy also tries to auto-create each type as a side effect of the +# first `op.create_table()` that uses a column of that type, colliding with +# the explicit `enum_type.create(...)` call and raising DuplicateObject. MOVIE_STATUS = postgresql.ENUM( "rumored", "planned", @@ -52,6 +57,7 @@ MOVIE_STATUS = postgresql.ENUM( "released", "canceled", name="moviestatus_enum", + create_type=False, ) SERIES_STATUS = postgresql.ENUM( "planned", @@ -61,23 +67,29 @@ SERIES_STATUS = postgresql.ENUM( "ended", "canceled", name="seriesstatus_enum", + create_type=False, ) ARTWORK_TYPE = postgresql.ENUM( "poster", "backdrop", "logo", "profile", "still", "banner", "thumbnail", name="artworktype_enum", + create_type=False, ) VIDEO_TYPE = postgresql.ENUM( "trailer", "teaser", "clip", "featurette", "behind_the_scenes", "interview", "other", name="videotype_enum", + create_type=False, ) COMPANY_TYPE = postgresql.ENUM( - "production_company", "network", "studio", "distributor", name="companytype_enum" + "production_company", "network", "studio", "distributor", name="companytype_enum", + create_type=False, ) INGESTION_JOB_STATUS = postgresql.ENUM( - "pending", "running", "succeeded", "failed", "retrying", name="ingestionjobstatus_enum" + "pending", "running", "succeeded", "failed", "retrying", name="ingestionjobstatus_enum", + create_type=False, ) MATCH_CONFIDENCE = postgresql.ENUM( - "exact", "high", "medium", "low", "ambiguous", "new", name="matchconfidence_enum" + "exact", "high", "medium", "low", "ambiguous", "new", name="matchconfidence_enum", + create_type=False, )