Skip to content

Commit 7f23c27

Browse files
author
Andrei Neagu
committed
added tested migration
1 parent c888fcc commit 7f23c27

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""adds template_type to projects
2+
3+
Revision ID: e145eeeae58e
4+
Revises: 0d52976dc616
5+
Create Date: 2025-05-13 09:35:41.864576+00:00
6+
7+
"""
8+
9+
import sqlalchemy as sa
10+
from alembic import op
11+
12+
# revision identifiers, used by Alembic.
13+
revision = "e145eeeae58e"
14+
down_revision = "0d52976dc616"
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.add_column(
22+
"projects",
23+
sa.Column(
24+
"template_type",
25+
sa.Enum("TEMPLATE", "STANDARD", name="projecttype"),
26+
nullable=True,
27+
),
28+
)
29+
# Update existing template projects
30+
op.execute("UPDATE projects SET template_type='TEMPLATE' WHERE type='TEMPLATE'")
31+
# ### end Alembic commands ###
32+
33+
34+
def downgrade():
35+
# ### commands auto generated by Alembic - please adjust! ###
36+
op.drop_column("projects", "template_type")
37+
# ### end Alembic commands ###

packages/postgres-database/src/simcore_postgres_database/models/projects.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ class ProjectType(enum.Enum):
1616
STANDARD = "STANDARD"
1717

1818

19+
class ProjectTemplateType(enum.Enum):
20+
TEMPLATE = "TEMPLATE"
21+
TUTORIAL = "TUTORIAL"
22+
HYPERTOOL = "HYPERTOOL"
23+
24+
1925
projects = sa.Table(
2026
"projects",
2127
metadata,
@@ -29,6 +35,13 @@ class ProjectType(enum.Enum):
2935
default=ProjectType.STANDARD,
3036
doc="Either standard or template types",
3137
),
38+
sa.Column(
39+
"template_type",
40+
sa.Enum(ProjectType),
41+
nullable=True,
42+
default=None,
43+
doc="None if type is STANDARD, otherwise it is one of the ProjectTemplateType",
44+
),
3245
sa.Column(
3346
"uuid",
3447
sa.String,

0 commit comments

Comments
 (0)