Skip to content

Commit 4d41f32

Browse files
committed
Update migration
1 parent cc5dd43 commit 4d41f32

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

alembic/versions/281723ba07be_add_cms_content_table.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@
1919

2020

2121
def upgrade():
22+
cms_types_enum = sa.Enum(
23+
"JOKE", "QUESTION", "FACT", "QUOTE", name="enum_cms_content_type"
24+
)
25+
cms_types_enum.create(op.get_bind(), checkfirst=True)
26+
2227
op.create_table(
2328
"cms_content",
2429
sa.Column(
2530
"id", sa.UUID(), server_default=sa.text("gen_random_uuid()"), nullable=False
2631
),
2732
sa.Column(
2833
"type",
29-
sa.Enum("JOKE", "QUESTION", "FACT", "QUOTE", name="enum_cms_content_type"),
34+
cms_types_enum,
3035
nullable=False,
3136
),
3237
sa.Column("content", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
@@ -56,3 +61,7 @@ def downgrade():
5661
op.drop_index(op.f("ix_cms_content_type"), table_name="cms_content")
5762
op.drop_index(op.f("ix_cms_content_id"), table_name="cms_content")
5863
op.drop_table("cms_content")
64+
65+
op.execute("DROP TYPE enum_cms_content_type")
66+
genresource = sa.Enum(name="enum_cms_content_type")
67+
genresource.drop(op.get_bind(), checkfirst=True)

0 commit comments

Comments
 (0)