Skip to content

Commit 4659473

Browse files
authored
πŸ› Database: added comp_tasks submit column back for legacy services (πŸ—ƒοΈ) (#7003)
1 parent fee208d commit 4659473

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""add deprecated submit column
2+
3+
Revision ID: 307017ee1a49
4+
Revises: 1e3c9c804fec
5+
Create Date: 2025-01-06 12:53:51.604189+00:00
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '307017ee1a49'
14+
down_revision = '1e3c9c804fec'
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('comp_tasks', sa.Column('submit', sa.DateTime(timezone=True), server_default=sa.text("'1900-01-01T00:00:00Z'::timestamptz"), nullable=True))
22+
# ### end Alembic commands ###
23+
24+
25+
def downgrade():
26+
# ### commands auto generated by Alembic - please adjust! ###
27+
op.drop_column('comp_tasks', 'submit')
28+
# ### end Alembic commands ###

β€Žpackages/postgres-database/src/simcore_postgres_database/models/comp_tasks.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
""" Computational Tasks Table
2-
3-
"""
1+
"""Computational Tasks Table"""
42

53
import enum
64

@@ -102,6 +100,14 @@ class NodeClass(enum.Enum):
102100
nullable=True,
103101
doc="Harware information of this task",
104102
),
103+
# deprecated columns must be kept due to legacy services
104+
# utc timestamps for submission/start/end
105+
sa.Column(
106+
"submit",
107+
sa.DateTime(timezone=True),
108+
server_default=sa.text("'1900-01-01T00:00:00Z'::timestamptz"),
109+
doc="[DEPRECATED unused but kept for legacy services and must be filled with a default value of 1 January 1900]",
110+
),
105111
# ------
106112
sa.UniqueConstraint("project_id", "node_id", name="project_node_uniqueness"),
107113
)

β€Žservices/director-v2/src/simcore_service_director_v2/models/comp_tasks.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ class CompTaskAtDB(BaseModel):
150150
pricing_info: dict | None
151151
hardware_info: HardwareInfo
152152

153+
submit: dt.datetime | None = Field(
154+
default=None, deprecated=True, description="Required for legacy services"
155+
)
156+
153157
@field_validator("state", mode="before")
154158
@classmethod
155159
def _convert_state_from_state_type_enum_if_needed(cls, v):
@@ -238,7 +242,9 @@ def to_db_model(self, **exclusion_rules) -> dict[str, Any]:
238242
"pricing_unit_id": 1,
239243
"pricing_unit_cost_id": 1,
240244
},
241-
"hardware_info": next(iter(HardwareInfo.model_config["json_schema_extra"]["examples"])), # type: ignore
245+
"hardware_info": next(
246+
iter(HardwareInfo.model_config["json_schema_extra"]["examples"]) # type: ignore
247+
),
242248
}
243249
for image_example in Image.model_config["json_schema_extra"]["examples"] # type: ignore
244250
]

0 commit comments

Comments
Β (0)