Skip to content

Commit 29f60e0

Browse files
author
Andrei Neagu
committed
fixed migration script
1 parent 5579039 commit 29f60e0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/postgres-database/src/simcore_postgres_database/migration/versions/219608f5a9c3_add_template_type_to_projects.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@
1818

1919
def upgrade():
2020
# ### commands auto generated by Alembic - please adjust! ###
21+
# Create enum type first
22+
project_template_type = sa.Enum(
23+
"TEMPLATE", "TUTORIAL", "HYPERTOOL", name="projecttemplatetype"
24+
)
25+
project_template_type.create(op.get_bind())
26+
27+
# Then add column using the enum type
2128
op.add_column(
2229
"projects",
2330
sa.Column(
2431
"template_type",
25-
sa.Enum("TEMPLATE", "TUTORIAL", "HYPERTOOL", name="projecttemplatetype"),
32+
project_template_type,
2633
nullable=True,
34+
default=None,
2735
),
2836
)
2937
# Update existing template projects
@@ -34,4 +42,6 @@ def upgrade():
3442
def downgrade():
3543
# ### commands auto generated by Alembic - please adjust! ###
3644
op.drop_column("projects", "template_type")
45+
# Drop the enum type after dropping the column
46+
sa.Enum(name="projecttemplatetype").drop(op.get_bind())
3747
# ### end Alembic commands ###

0 commit comments

Comments
 (0)