fix(models,db): delegate timestamps to DB server and configure connection pool

- Replace default=datetime.utcnow with server_default=func.now() across all 16 models (17 columns) for consistent, timezone-aware timestamps from PostgreSQL

- Upgrade DateTime columns to DateTime(timezone=True) for timestamptz storage

- Configure SQLAlchemy engine pool: pool_size=20, max_overflow=10, pool_recycle=3600, pool_pre_ping=True

- Remove unused datetime imports from model files
This commit is contained in:
2026-02-18 11:52:15 +01:00
parent a4a2adccee
commit 51c927394d
18 changed files with 42 additions and 70 deletions

View File

@@ -1,9 +1,7 @@
"""Worklog model — immutable internal time-tracking records."""
import uuid
from datetime import datetime
from sqlalchemy import Column, String, Integer, DateTime, ForeignKey, Text, Index
from sqlalchemy import Column, String, Integer, DateTime, ForeignKey, Text, Index, func
from sqlalchemy.dialects.postgresql import UUID, JSONB
from sqlalchemy.orm import relationship
@@ -32,7 +30,7 @@ class Worklog(Base):
tempo_synced = Column(DateTime)
tempo_worklog_id = Column(String(100))
integrity_hash = Column(String(64))
created_at = Column(DateTime, default=datetime.utcnow)
created_at = Column(DateTime(timezone=True), server_default=func.now())
extra_metadata = Column("metadata", JSONB, default={})
user = relationship("User", foreign_keys=[user_id])