Skip to content

Commit 2435f57

Browse files
Add timezone to scientific_artifact.experiment_date (#326)
1 parent 7fbcc5b commit 2435f57

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""Add timezone to experiment_date
2+
3+
Revision ID: 77e367d5b4a5
4+
Revises: 8a2a82a25cca
5+
Create Date: 2025-08-08 18:19:49.192617
6+
7+
"""
8+
9+
from typing import Sequence, Union
10+
11+
from alembic import op
12+
import sqlalchemy as sa
13+
from sqlalchemy.dialects import postgresql
14+
15+
from sqlalchemy import Text
16+
import app.db.types
17+
18+
# revision identifiers, used by Alembic.
19+
revision: str = "77e367d5b4a5"
20+
down_revision: Union[str, None] = "8a2a82a25cca"
21+
branch_labels: Union[str, Sequence[str], None] = None
22+
depends_on: Union[str, Sequence[str], None] = None
23+
24+
25+
def upgrade() -> None:
26+
# ### commands auto generated by Alembic - please adjust! ###
27+
op.alter_column(
28+
"scientific_artifact",
29+
"experiment_date",
30+
existing_type=postgresql.TIMESTAMP(),
31+
type_=sa.DateTime(timezone=True),
32+
existing_nullable=True,
33+
)
34+
# ### end Alembic commands ###
35+
36+
37+
def downgrade() -> None:
38+
# ### commands auto generated by Alembic - please adjust! ###
39+
op.alter_column(
40+
"scientific_artifact",
41+
"experiment_date",
42+
existing_type=sa.DateTime(timezone=True),
43+
type_=postgresql.TIMESTAMP(),
44+
existing_nullable=True,
45+
)
46+
# ### end Alembic commands ###

app/db/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ class ScientificArtifact(Entity, SubjectMixin, LocationMixin, LicensedMixin):
557557

558558
id: Mapped[uuid.UUID] = mapped_column(ForeignKey("entity.id"), primary_key=True)
559559

560-
experiment_date: Mapped[datetime | None] = mapped_column(DateTime)
560+
experiment_date: Mapped[datetime | None]
561561
contact_email: Mapped[str | None]
562562
published_in: Mapped[str | None]
563563

0 commit comments

Comments
 (0)