feat: use custom type to handle existing naive datetimes

This commit is contained in:
Iain Learmonth 2024-12-06 18:02:59 +00:00
parent e22abb383c
commit 39bdac1ecf
45 changed files with 210 additions and 84 deletions

View file

@ -6,6 +6,7 @@ from sqlalchemy.orm import Mapped, mapped_column
from app.extensions import db
from app.models.activity import Activity
from app.models.types import AwareDateTime
class AlarmState(enum.Enum):
@ -30,8 +31,8 @@ class Alarm(db.Model): # type: ignore
target: Mapped[str]
aspect: Mapped[str]
alarm_state: Mapped[AlarmState] = mapped_column(default=AlarmState.UNKNOWN)
state_changed: Mapped[datetime] = mapped_column(db.DateTime(timezone=True))
last_updated: Mapped[datetime] = mapped_column(db.DateTime(timezone=True))
state_changed: Mapped[datetime] = mapped_column(AwareDateTime())
last_updated: Mapped[datetime] = mapped_column(AwareDateTime())
text: Mapped[str]
@classmethod