Sadeep Sachintha commited on
Commit ·
09f1e96
1
Parent(s): b387bc5
fix: use timezone-naive UTC for created_at to avoid pgsql dataerror
Browse files- db/models.py +3 -3
db/models.py
CHANGED
|
@@ -8,7 +8,7 @@ class User(Base):
|
|
| 8 |
__tablename__ = "users"
|
| 9 |
|
| 10 |
chat_id = Column(BigInteger, primary_key=True, index=True)
|
| 11 |
-
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
|
| 12 |
|
| 13 |
subscriptions = relationship("Subscription", back_populates="user", cascade="all, delete-orphan")
|
| 14 |
thresholds = relationship("Threshold", back_populates="user", cascade="all, delete-orphan")
|
|
@@ -22,7 +22,7 @@ class Subscription(Base):
|
|
| 22 |
target_currency = Column(String(3), nullable=False)
|
| 23 |
# Frequency could be 'daily', 'hourly'
|
| 24 |
frequency = Column(String(20), default="daily")
|
| 25 |
-
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
|
| 26 |
|
| 27 |
user = relationship("User", back_populates="subscriptions")
|
| 28 |
|
|
@@ -36,6 +36,6 @@ class Threshold(Base):
|
|
| 36 |
condition = Column(String(5), nullable=False) # e.g., '<', '>', '<=', '>='
|
| 37 |
target_value = Column(Float, nullable=False)
|
| 38 |
is_active = Column(Boolean, default=True)
|
| 39 |
-
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
|
| 40 |
|
| 41 |
user = relationship("User", back_populates="thresholds")
|
|
|
|
| 8 |
__tablename__ = "users"
|
| 9 |
|
| 10 |
chat_id = Column(BigInteger, primary_key=True, index=True)
|
| 11 |
+
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc).replace(tzinfo=None))
|
| 12 |
|
| 13 |
subscriptions = relationship("Subscription", back_populates="user", cascade="all, delete-orphan")
|
| 14 |
thresholds = relationship("Threshold", back_populates="user", cascade="all, delete-orphan")
|
|
|
|
| 22 |
target_currency = Column(String(3), nullable=False)
|
| 23 |
# Frequency could be 'daily', 'hourly'
|
| 24 |
frequency = Column(String(20), default="daily")
|
| 25 |
+
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc).replace(tzinfo=None))
|
| 26 |
|
| 27 |
user = relationship("User", back_populates="subscriptions")
|
| 28 |
|
|
|
|
| 36 |
condition = Column(String(5), nullable=False) # e.g., '<', '>', '<=', '>='
|
| 37 |
target_value = Column(Float, nullable=False)
|
| 38 |
is_active = Column(Boolean, default=True)
|
| 39 |
+
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc).replace(tzinfo=None))
|
| 40 |
|
| 41 |
user = relationship("User", back_populates="thresholds")
|