Skip to content

Commit a79bc7e

Browse files
update script
1 parent be56df7 commit a79bc7e

File tree

2 files changed

+43
-47
lines changed

2 files changed

+43
-47
lines changed
Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,39 @@
11
"""Move projects workbench
22
3-
Revision ID: 5c69e5661f45
3+
Revision ID: 50af59b6c37a
44
Revises: 307017ee1a49
5-
Create Date: 2025-01-13 13:45:47.583609+00:00
5+
Create Date: 2025-01-15 12:39:46.219516+00:00
66
77
"""
88
from alembic import op
99
import sqlalchemy as sa
1010
from sqlalchemy.dialects import postgresql
1111

1212
# revision identifiers, used by Alembic.
13-
revision = '5c69e5661f45'
13+
revision = '50af59b6c37a'
1414
down_revision = '307017ee1a49'
1515
branch_labels = None
1616
depends_on = None
1717

1818

1919
def upgrade():
20-
# ### commands auto generated by Alembic - please adjust! ###
21-
op.add_column('projects_nodes', sa.Column('key', sa.String(), nullable=False))
22-
op.add_column('projects_nodes', sa.Column('version', sa.String(), nullable=False))
23-
op.add_column('projects_nodes', sa.Column('label', sa.String(), nullable=False))
24-
op.add_column('projects_nodes', sa.Column('progress', sa.Numeric(), nullable=True))
25-
op.add_column('projects_nodes', sa.Column('thumbnail', sa.String(), nullable=True))
26-
op.add_column('projects_nodes', sa.Column('input_access', postgresql.JSONB(astext_type=sa.Text()), nullable=True))
27-
op.add_column('projects_nodes', sa.Column('input_nodes', postgresql.JSONB(astext_type=sa.Text()), nullable=True))
28-
op.add_column('projects_nodes', sa.Column('inputs', postgresql.JSONB(astext_type=sa.Text()), nullable=True))
29-
op.add_column('projects_nodes', sa.Column('inputs_required', postgresql.JSONB(astext_type=sa.Text()), nullable=True))
30-
op.add_column('projects_nodes', sa.Column('inputs_units', postgresql.JSONB(astext_type=sa.Text()), nullable=True))
31-
op.add_column('projects_nodes', sa.Column('output_nodes', postgresql.JSONB(astext_type=sa.Text()), nullable=True))
32-
op.add_column('projects_nodes', sa.Column('outputs', postgresql.JSONB(astext_type=sa.Text()), nullable=True))
33-
op.add_column('projects_nodes', sa.Column('run_hash', sa.String(), nullable=True))
34-
op.add_column('projects_nodes', sa.Column('state', postgresql.JSONB(astext_type=sa.Text()), nullable=True))
35-
op.add_column('projects_nodes', sa.Column('parent', sa.String(), nullable=True))
36-
op.add_column('projects_nodes', sa.Column('boot_options', postgresql.JSONB(astext_type=sa.Text()), nullable=True))
37-
# ### end Alembic commands ###
20+
op.add_column('projects_nodes', sa.Column('key', sa.String(), nullable=False, comment='Distinctive name (based on the Docker registry path)'))
21+
op.add_column('projects_nodes', sa.Column('version', sa.String(), nullable=False, comment='Semantic version number'))
22+
op.add_column('projects_nodes', sa.Column('label', sa.String(), nullable=False, comment='Short name '))
23+
op.add_column('projects_nodes', sa.Column('progress', sa.Numeric(), nullable=True, comment='Progress value'))
24+
op.add_column('projects_nodes', sa.Column('thumbnail', sa.String(), nullable=True, comment='Url of the latest screenshot'))
25+
op.add_column('projects_nodes', sa.Column('input_access', postgresql.JSONB(astext_type=sa.Text()), nullable=True, comment='Map with key - access level pairs'))
26+
op.add_column('projects_nodes', sa.Column('input_nodes', postgresql.JSONB(astext_type=sa.Text()), nullable=True, comment='IDs of the nodes where is connected to'))
27+
op.add_column('projects_nodes', sa.Column('inputs', postgresql.JSONB(astext_type=sa.Text()), nullable=True, comment='Input properties values'))
28+
op.add_column('projects_nodes', sa.Column('inputs_required', postgresql.JSONB(astext_type=sa.Text()), nullable=True, comment='Required input IDs'))
29+
op.add_column('projects_nodes', sa.Column('inputs_units', postgresql.JSONB(astext_type=sa.Text()), nullable=True, comment='Input units'))
30+
op.add_column('projects_nodes', sa.Column('output_nodes', postgresql.JSONB(astext_type=sa.Text()), nullable=True, comment='Node IDs of those connected to the output'))
31+
op.add_column('projects_nodes', sa.Column('outputs', postgresql.JSONB(astext_type=sa.Text()), nullable=True, comment='Output properties values'))
32+
op.add_column('projects_nodes', sa.Column('run_hash', sa.String(), nullable=True, comment='HEX digest of the resolved inputs + outputs hash at the time when the last outputs were generated'))
33+
op.add_column('projects_nodes', sa.Column('state', postgresql.JSONB(astext_type=sa.Text()), nullable=True, comment='State'))
34+
op.add_column('projects_nodes', sa.Column('parent', sa.String(), nullable=True, comment="Parent's (group-nodes) node ID"))
35+
op.add_column('projects_nodes', sa.Column('boot_options', postgresql.JSONB(astext_type=sa.Text()), nullable=True, comment="Some services provide alternative parameters to be injected at boot time.The user selection should be stored here, and it will overwrite the services's defaults"))
3836

39-
# Populate the new columns with data from the workbench
4037
op.execute(
4138
"""
4239
UPDATE projects_nodes
@@ -83,10 +80,11 @@ def upgrade():
8380
AND projects_nodes.node_id = subquery.node_id;
8481
"""
8582
)
86-
83+
op.alter_column("projects_nodes", "key", nullable=False)
84+
op.alter_column("projects_nodes", "version", nullable=False)
85+
op.alter_column("projects_nodes", "label", nullable=False)
8786

8887
def downgrade():
89-
# ### commands auto generated by Alembic - please adjust! ###
9088
op.drop_column('projects_nodes', 'boot_options')
9189
op.drop_column('projects_nodes', 'parent')
9290
op.drop_column('projects_nodes', 'state')
@@ -103,4 +101,3 @@ def downgrade():
103101
op.drop_column('projects_nodes', 'label')
104102
op.drop_column('projects_nodes', 'version')
105103
op.drop_column('projects_nodes', 'key')
106-
# ### end Alembic commands ###

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

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
nullable=False,
2626
autoincrement=True,
2727
primary_key=True,
28-
doc="Project node index",
28+
comment="Index of the project node",
2929
),
3030
sa.Column(
3131
"project_uuid",
@@ -38,21 +38,21 @@
3838
),
3939
nullable=False,
4040
index=True,
41-
doc="Project unique identifier",
41+
comment="Unique identifier of the project",
4242
),
4343
sa.Column(
4444
"node_id",
4545
sa.String,
4646
nullable=False,
4747
index=True,
48-
doc="Node unique identifier",
48+
comment="Unique identifier of the node",
4949
),
5050
sa.Column(
5151
"required_resources",
5252
JSONB,
5353
nullable=False,
5454
server_default=sa.text("'{}'::jsonb"),
55-
doc="Node required resources",
55+
comment="Required resources",
5656
),
5757
# TIME STAMPS ----
5858
column_created_datetime(timezone=True),
@@ -61,97 +61,97 @@
6161
"key",
6262
sa.String,
6363
nullable=False,
64-
doc="Distinctive name for the node based on the docker registry path",
64+
comment="Distinctive name (based on the Docker registry path)",
6565
),
6666
sa.Column(
6767
"version",
6868
sa.String,
6969
nullable=False,
70-
doc="Semantic version number of the node",
70+
comment="Semantic version number",
7171
),
7272
sa.Column(
7373
"label",
7474
sa.String,
7575
nullable=False,
76-
doc="Short name of the node",
76+
comment="Short name ",
7777
),
7878
sa.Column(
7979
"progress",
8080
sa.Numeric,
8181
nullable=True,
82-
doc="Node progress value",
82+
comment="Progress value",
8383
),
8484
sa.Column(
8585
"thumbnail",
8686
sa.String,
8787
nullable=True,
88-
doc="Url of the latest screenshot of the node",
88+
comment="Url of the latest screenshot",
8989
),
9090
sa.Column(
9191
"input_access",
9292
JSONB,
9393
nullable=True,
94-
doc="Map with key - access level pairs",
94+
comment="Map with key - access level pairs",
9595
),
9696
sa.Column(
9797
"input_nodes",
9898
JSONB, # Array
9999
nullable=True,
100-
doc="Node IDs of where the node is connected to",
100+
comment="IDs of the nodes where is connected to",
101101
),
102102
sa.Column(
103103
"inputs",
104104
JSONB,
105105
nullable=True,
106-
doc="Input properties values",
106+
comment="Input properties values",
107107
),
108108
sa.Column(
109109
"inputs_required",
110110
JSONB, # Array
111111
nullable=True,
112-
doc="Input IDs that are required",
112+
comment="Required input IDs",
113113
),
114114
sa.Column(
115115
"inputs_units",
116116
JSONB,
117117
nullable=True,
118-
doc="Input unit values",
118+
comment="Input units",
119119
),
120120
sa.Column(
121121
"output_nodes",
122122
JSONB, # Array
123123
nullable=True,
124-
doc="Node IDs of those connected to the output",
124+
comment="Node IDs of those connected to the output",
125125
),
126126
sa.Column(
127127
"outputs",
128128
JSONB,
129129
nullable=True,
130-
doc="Output properties values",
130+
comment="Output properties values",
131131
),
132132
# sa.Column(
133133
# "output_node",
134134
# sa.BOOLEAN,
135135
# nullable=True,
136-
# doc="Deprecated",
136+
# comment="Deprecated",
137137
# ),
138138
sa.Column(
139139
"run_hash",
140140
sa.String,
141141
nullable=True,
142-
doc="HEX digest of the resolved inputs + outputs hash at the time when the last outputs were generated",
142+
comment="HEX digest of the resolved inputs + outputs hash at the time when the last outputs were generated",
143143
),
144144
sa.Column(
145145
"state",
146146
JSONB,
147147
nullable=True,
148-
doc="Node state",
148+
comment="State",
149149
),
150150
sa.Column(
151151
"parent",
152152
sa.String,
153153
nullable=True,
154-
doc="Parent's (group-nodes) node ID",
154+
comment="Parent's (group-nodes) node ID",
155155
),
156156
# sa.Column(
157157
# "position",
@@ -163,11 +163,10 @@
163163
"boot_options",
164164
JSONB,
165165
nullable=True,
166-
doc="Some services provide alternative parameters to be injected at boot time."
166+
comment="Some services provide alternative parameters to be injected at boot time."
167167
"The user selection should be stored here, and it will overwrite the services's defaults",
168168
),
169169
sa.UniqueConstraint("project_uuid", "node_id"),
170170
)
171171

172-
173172
register_modified_datetime_auto_update_trigger(projects_nodes)

0 commit comments

Comments
 (0)