Skip to content

Commit

Permalink
πŸ› Database: added comp_tasks submit column back for legacy services (…
Browse files Browse the repository at this point in the history
β€¦πŸ—ƒοΈ) (ITISFoundation#7003)
  • Loading branch information
sanderegg authored Jan 7, 2025
1 parent fee208d commit 4659473
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""add deprecated submit column
Revision ID: 307017ee1a49
Revises: 1e3c9c804fec
Create Date: 2025-01-06 12:53:51.604189+00:00
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '307017ee1a49'
down_revision = '1e3c9c804fec'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('comp_tasks', sa.Column('submit', sa.DateTime(timezone=True), server_default=sa.text("'1900-01-01T00:00:00Z'::timestamptz"), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('comp_tasks', 'submit')
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
""" Computational Tasks Table
"""
"""Computational Tasks Table"""

import enum

Expand Down Expand Up @@ -102,6 +100,14 @@ class NodeClass(enum.Enum):
nullable=True,
doc="Harware information of this task",
),
# deprecated columns must be kept due to legacy services
# utc timestamps for submission/start/end
sa.Column(
"submit",
sa.DateTime(timezone=True),
server_default=sa.text("'1900-01-01T00:00:00Z'::timestamptz"),
doc="[DEPRECATED unused but kept for legacy services and must be filled with a default value of 1 January 1900]",
),
# ------
sa.UniqueConstraint("project_id", "node_id", name="project_node_uniqueness"),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ class CompTaskAtDB(BaseModel):
pricing_info: dict | None
hardware_info: HardwareInfo

submit: dt.datetime | None = Field(
default=None, deprecated=True, description="Required for legacy services"
)

@field_validator("state", mode="before")
@classmethod
def _convert_state_from_state_type_enum_if_needed(cls, v):
Expand Down Expand Up @@ -238,7 +242,9 @@ def to_db_model(self, **exclusion_rules) -> dict[str, Any]:
"pricing_unit_id": 1,
"pricing_unit_cost_id": 1,
},
"hardware_info": next(iter(HardwareInfo.model_config["json_schema_extra"]["examples"])), # type: ignore
"hardware_info": next(
iter(HardwareInfo.model_config["json_schema_extra"]["examples"]) # type: ignore
),
}
for image_example in Image.model_config["json_schema_extra"]["examples"] # type: ignore
]
Expand Down

0 comments on commit 4659473

Please sign in to comment.