File tree Expand file tree Collapse file tree 2 files changed +50
-2
lines changed
packages/postgres-database/src/simcore_postgres_database Expand file tree Collapse file tree 2 files changed +50
-2
lines changed Original file line number Diff line number Diff line change 1+ """add state type unknown
2+
3+ Revision ID: 06eafd25d004
4+ Revises: ec4f62595e0c
5+ Create Date: 2025-09-01 12:25:25.617790+00:00
6+
7+ """
8+
9+ from alembic import op
10+
11+ # revision identifiers, used by Alembic.
12+ revision = "06eafd25d004"
13+ down_revision = "ec4f62595e0c"
14+ branch_labels = None
15+ depends_on = None
16+
17+
18+ def upgrade ():
19+ op .execute ("ALTER TYPE statetype ADD VALUE 'UNKNOWN'" )
20+
21+
22+ def downgrade () -> None :
23+ # NOTE: PostgreSQL doesn't support removing enum values directly
24+ # This downgrades only ensure that StateType.UNKNOWN is not used
25+ #
26+
27+ # Find all tables and columns that use statetype enum
28+ result = op .get_bind ().execute (
29+ """
30+ SELECT t.table_name, c.column_name, c.column_default
31+ FROM information_schema.columns c
32+ JOIN information_schema.tables t ON c.table_name = t.table_name
33+ WHERE c.udt_name = 'statetype'
34+ AND t.table_schema = 'public'
35+ """
36+ )
37+
38+ tables_columns = result .fetchall ()
39+
40+ # Update UNKNOWN states to FAILED in all affected tables
41+ for table_name , column_name , _ in tables_columns :
42+ op .execute (
43+ f"""
44+ UPDATE { table_name }
45+ SET { column_name } = 'FAILED'
46+ WHERE { column_name } = 'UNKNOWN'
47+ """
48+ )
Original file line number Diff line number Diff line change 1- """ Computational Pipeline Table
1+ """Computational Pipeline Table"""
22
3- """
43import enum
54import uuid
65
@@ -24,6 +23,7 @@ class StateType(enum.Enum):
2423 ABORTED = "ABORTED"
2524 WAITING_FOR_RESOURCES = "WAITING_FOR_RESOURCES"
2625 WAITING_FOR_CLUSTER = "WAITING_FOR_CLUSTER"
26+ UNKNOWN = "UNKNOWN"
2727
2828
2929def _new_uuid ():
You can’t perform that action at this time.
0 commit comments