Skip to content

Commit a9ae1b9

Browse files
committed
convert comp_tasks timestamps to tz aware
1 parent cf77463 commit a9ae1b9

File tree

2 files changed

+78
-3
lines changed

2 files changed

+78
-3
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
"""add_timezone_comp_tasks
2+
3+
Revision ID: 7ad64e963e0f
4+
Revises: b7f23f6d8aa2
5+
Create Date: 2024-11-27 22:28:51.898433+00:00
6+
7+
"""
8+
import sqlalchemy as sa
9+
from alembic import op
10+
from sqlalchemy.dialects import postgresql
11+
12+
# revision identifiers, used by Alembic.
13+
revision = "7ad64e963e0f"
14+
down_revision = "b7f23f6d8aa2"
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.alter_column(
22+
"comp_tasks",
23+
"submit",
24+
existing_type=postgresql.TIMESTAMP(),
25+
type_=sa.DateTime(timezone=True),
26+
existing_nullable=True,
27+
)
28+
op.alter_column(
29+
"comp_tasks",
30+
"start",
31+
existing_type=postgresql.TIMESTAMP(),
32+
type_=sa.DateTime(timezone=True),
33+
existing_nullable=True,
34+
)
35+
op.alter_column(
36+
"comp_tasks",
37+
"end",
38+
existing_type=postgresql.TIMESTAMP(),
39+
type_=sa.DateTime(timezone=True),
40+
existing_nullable=True,
41+
)
42+
# ### end Alembic commands ###
43+
44+
45+
def downgrade():
46+
# ### commands auto generated by Alembic - please adjust! ###
47+
op.alter_column(
48+
"comp_tasks",
49+
"end",
50+
existing_type=sa.DateTime(timezone=True),
51+
type_=postgresql.TIMESTAMP(),
52+
existing_nullable=True,
53+
)
54+
op.alter_column(
55+
"comp_tasks",
56+
"start",
57+
existing_type=sa.DateTime(timezone=True),
58+
type_=postgresql.TIMESTAMP(),
59+
existing_nullable=True,
60+
)
61+
op.alter_column(
62+
"comp_tasks",
63+
"submit",
64+
existing_type=sa.DateTime(timezone=True),
65+
type_=postgresql.TIMESTAMP(),
66+
existing_nullable=True,
67+
)
68+
# ### end Alembic commands ###

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" Computational Tasks Table
22

33
"""
4+
45
import enum
56

67
import sqlalchemy as sa
@@ -77,9 +78,15 @@ class NodeClass(enum.Enum):
7778
doc="current progress of the task if available",
7879
),
7980
# utc timestamps for submission/start/end
80-
sa.Column("submit", sa.DateTime, doc="UTC timestamp for task submission"),
81-
sa.Column("start", sa.DateTime, doc="UTC timestamp when task started"),
82-
sa.Column("end", sa.DateTime, doc="UTC timestamp for task completion"),
81+
sa.Column(
82+
"submit", sa.DateTime(timezone=True), doc="UTC timestamp for task submission"
83+
),
84+
sa.Column(
85+
"start", sa.DateTime(timezone=True), doc="UTC timestamp when task started"
86+
),
87+
sa.Column(
88+
"end", sa.DateTime(timezone=True), doc="UTC timestamp for task completion"
89+
),
8390
sa.Column(
8491
"last_heartbeat",
8592
sa.DateTime(timezone=True),

0 commit comments

Comments
 (0)