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:
@@ -1,9 +1,7 @@
|
||||
"""DataSource model — registry of external data sources for import."""
|
||||
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Column, String, Text, Boolean, DateTime, Index
|
||||
from sqlalchemy import Column, String, Text, Boolean, DateTime, Index, func
|
||||
from sqlalchemy.dialects.postgresql import UUID, JSONB
|
||||
|
||||
from app.database import Base
|
||||
@@ -31,7 +29,7 @@ class DataSource(Base):
|
||||
last_sync_stats = Column(JSONB, nullable=True) # {"imported": X, "updated": Y, ...}
|
||||
sync_frequency = Column(String, nullable=True) # daily / weekly / monthly / manual
|
||||
config = Column(JSONB, nullable=True) # source-specific configuration
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
__table_args__ = (
|
||||
Index('ix_data_sources_type', 'type'),
|
||||
|
||||
Reference in New Issue
Block a user