Skip to content

Commit

Permalink
fix(persistence): postgres timestamp insertion (#2844)
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerHYang authored Apr 10, 2024
1 parent 3a6666c commit 3477bb9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions src/phoenix/db/migrations/versions/cf03bd6bae1d_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ def upgrade() -> None:
sa.Column("description", sa.String, nullable=True),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
sa.TIMESTAMP(timezone=True),
nullable=False,
server_default=sa.func.now(),
),
sa.Column(
"updated_at",
sa.DateTime(timezone=True),
sa.TIMESTAMP(timezone=True),
nullable=False,
server_default=sa.func.now(),
onupdate=sa.func.now(),
Expand All @@ -46,8 +46,8 @@ def upgrade() -> None:
# TODO(mikeldking): might not be the right place for this
sa.Column("session_id", sa.String, nullable=True),
sa.Column("trace_id", sa.String, nullable=False, unique=True),
sa.Column("start_time", sa.DateTime(timezone=True), nullable=False, index=True),
sa.Column("end_time", sa.DateTime(timezone=True), nullable=False),
sa.Column("start_time", sa.TIMESTAMP(timezone=True), nullable=False, index=True),
sa.Column("end_time", sa.TIMESTAMP(timezone=True), nullable=False),
sa.Column("latency_ms", sa.Float, nullable=False),
)

Expand All @@ -59,8 +59,8 @@ def upgrade() -> None:
sa.Column("parent_span_id", sa.String, nullable=True, index=True),
sa.Column("name", sa.String, nullable=False),
sa.Column("kind", sa.String, nullable=False),
sa.Column("start_time", sa.DateTime(timezone=True), nullable=False),
sa.Column("end_time", sa.DateTime(timezone=True), nullable=False),
sa.Column("start_time", sa.TIMESTAMP(timezone=True), nullable=False),
sa.Column("end_time", sa.TIMESTAMP(timezone=True), nullable=False),
sa.Column("attributes", sa.JSON, nullable=False),
sa.Column("events", sa.JSON, nullable=False),
sa.Column(
Expand Down Expand Up @@ -99,13 +99,13 @@ def upgrade() -> None:
),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
sa.TIMESTAMP(timezone=True),
nullable=False,
server_default=sa.func.now(),
),
sa.Column(
"updated_at",
sa.DateTime(timezone=True),
sa.TIMESTAMP(timezone=True),
nullable=False,
server_default=sa.func.now(),
onupdate=sa.func.now(),
Expand Down Expand Up @@ -138,13 +138,13 @@ def upgrade() -> None:
),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
sa.TIMESTAMP(timezone=True),
nullable=False,
server_default=sa.func.now(),
),
sa.Column(
"updated_at",
sa.DateTime(timezone=True),
sa.TIMESTAMP(timezone=True),
nullable=False,
server_default=sa.func.now(),
onupdate=sa.func.now(),
Expand Down Expand Up @@ -178,13 +178,13 @@ def upgrade() -> None:
),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
sa.TIMESTAMP(timezone=True),
nullable=False,
server_default=sa.func.now(),
),
sa.Column(
"updated_at",
sa.DateTime(timezone=True),
sa.TIMESTAMP(timezone=True),
nullable=False,
server_default=sa.func.now(),
onupdate=sa.func.now(),
Expand Down
4 changes: 2 additions & 2 deletions src/phoenix/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from sqlalchemy import (
JSON,
TIMESTAMP,
CheckConstraint,
DateTime,
Dialect,
ForeignKey,
MetaData,
Expand Down Expand Up @@ -33,7 +33,7 @@ class UtcTimeStamp(TypeDecorator[datetime]):
"""

cache_ok = True
impl = DateTime
impl = TIMESTAMP(timezone=True)
_LOCAL_TIMEZONE = datetime.now(timezone.utc).astimezone().tzinfo

def process_bind_param(
Expand Down

0 comments on commit 3477bb9

Please sign in to comment.