Skip to content

Commit c79dc06

Browse files
add server default to dag field
1 parent 2faca3b commit c79dc06

File tree

4 files changed

+34
-69
lines changed

4 files changed

+34
-69
lines changed

packages/postgres-database/src/simcore_postgres_database/migration/versions/bc978c56397b_add_comp_run_snapshot_tasks_table_2.py

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""add comp_run_snapshot_tasks table
22
3-
Revision ID: 4e9ac9ea7eca
3+
Revision ID: e89eae27fb3f
44
Revises: 278daef7e99d
5-
Create Date: 2025-05-28 14:00:23.502544+00:00
5+
Create Date: 2025-05-29 16:52:00.435268+00:00
66
77
"""
88

@@ -11,7 +11,7 @@
1111
from sqlalchemy.dialects import postgresql
1212

1313
# revision identifiers, used by Alembic.
14-
revision = "4e9ac9ea7eca"
14+
revision = "e89eae27fb3f"
1515
down_revision = "278daef7e99d"
1616
branch_labels = None
1717
depends_on = None
@@ -69,13 +69,34 @@ def upgrade():
6969
op.add_column(
7070
"comp_runs",
7171
sa.Column(
72-
"dag_adjacency_list", postgresql.JSONB(astext_type=sa.Text()), nullable=True
72+
"dag_adjacency_list",
73+
postgresql.JSONB(astext_type=sa.Text()),
74+
server_default=sa.text("'{}'::jsonb"),
75+
nullable=False,
7376
),
7477
)
7578
# ### end Alembic commands ###
7679
op.execute("ALTER TABLE comp_run_snapshot_tasks ADD COLUMN node_class nodeclass;")
7780
op.execute("ALTER TABLE comp_run_snapshot_tasks ADD COLUMN state statetype;")
7881

82+
op.alter_column(
83+
"comp_run_snapshot_tasks",
84+
"state",
85+
existing_type=postgresql.ENUM(
86+
"NOT_STARTED",
87+
"PUBLISHED",
88+
"PENDING",
89+
"RUNNING",
90+
"SUCCESS",
91+
"FAILED",
92+
"ABORTED",
93+
"WAITING_FOR_RESOURCES",
94+
"WAITING_FOR_CLUSTER",
95+
name="statetype",
96+
),
97+
nullable=False,
98+
)
99+
79100

80101
def downgrade():
81102
# ### commands auto generated by Alembic - please adjust! ###

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@
9999
doc="the run uses on demand clusters",
100100
),
101101
sa.Column(
102-
"dag_adjacency_list", JSONB, doc="Adjacency list for the pipeline's graph"
102+
"dag_adjacency_list",
103+
JSONB,
104+
doc="Adjacency list for the pipeline's graph",
105+
server_default=sa.text("'{}'::jsonb"),
106+
nullable=False,
103107
),
104108
sa.UniqueConstraint("project_uuid", "user_id", "iteration"),
105109
sa.Index("ix_comp_runs_user_id", "user_id"),

packages/postgres-database/tests/test_utils_comp_runs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async def sample_comp_runs(asyncpg_engine: AsyncEngine):
3636
"processed": None,
3737
"metadata": None,
3838
"use_on_demand_clusters": False,
39-
"dag_adjacency_list": None,
39+
"dag_adjacency_list": {},
4040
},
4141
{
4242
"run_id": 2,
@@ -57,7 +57,7 @@ async def sample_comp_runs(asyncpg_engine: AsyncEngine):
5757
"processed": None,
5858
"metadata": None,
5959
"use_on_demand_clusters": False,
60-
"dag_adjacency_list": None,
60+
"dag_adjacency_list": {},
6161
},
6262
{
6363
"run_id": 3,
@@ -78,7 +78,7 @@ async def sample_comp_runs(asyncpg_engine: AsyncEngine):
7878
"processed": None,
7979
"metadata": None,
8080
"use_on_demand_clusters": False,
81-
"dag_adjacency_list": None,
81+
"dag_adjacency_list": {},
8282
},
8383
{
8484
"run_id": 4,
@@ -99,7 +99,7 @@ async def sample_comp_runs(asyncpg_engine: AsyncEngine):
9999
"processed": None,
100100
"metadata": None,
101101
"use_on_demand_clusters": False,
102-
"dag_adjacency_list": None,
102+
"dag_adjacency_list": {},
103103
},
104104
],
105105
)

0 commit comments

Comments
 (0)