DB review safe-fix: naive-UTC timestamp defaults (drop db.func.now)
DB review found four DateTime columns defaulting to db.func.now() (MySQL session-timezone wall clock) while the rest of the schema stores naive UTC, so one schema mixed two clocks and to_dict() labelled the local values UTC with a 'Z' suffix. Switch application.dateadded, computers.installeddate, knowledgebase.lastupdated (default + onupdate), and slides.uploadeddate to the module-level naive-UTC _utcnow callable already used elsewhere (apitoken.py). ORM-side default only - no column-type change, no data migration; affects new/updated rows. Targeted tests pass (154); naming + pyflakes green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
"""Computer plugin models."""
|
||||
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from shopdb.api import db, BaseModel
|
||||
|
||||
|
||||
def _utcnow():
|
||||
# naive UTC to match the other DB DateTime columns (stored without tzinfo)
|
||||
return datetime.now(timezone.utc).replace(tzinfo=None)
|
||||
|
||||
|
||||
class ComputerType(BaseModel):
|
||||
"""
|
||||
Computer type classification.
|
||||
@@ -170,7 +177,7 @@ class ComputerInstalledApp(db.Model):
|
||||
# Raw version string from automated collection (when no curated AppVersion)
|
||||
installedversion = db.Column(db.String(100), nullable=True)
|
||||
isactive = db.Column(db.Boolean, default=True, nullable=False)
|
||||
installeddate = db.Column(db.DateTime, default=db.func.now())
|
||||
installeddate = db.Column(db.DateTime, default=_utcnow)
|
||||
|
||||
# Relationships
|
||||
computer = db.relationship('Computer', back_populates='installedapps')
|
||||
|
||||
Reference in New Issue
Block a user