Files
ServerKit/backend/app/models/image_update.py
T
Juan DenisandClaude Fable 5 2e3a735d5a refactor(models): SerializableMixin — mechanical to_dicts become introspection (plan 77 B2)
Opt-in to_dict over __table__.columns: auto-isoformat datetimes,
*_encrypted always dropped, __serialize_exclude__ for redacted columns,
serialize_extra() for computed fields (named to dodge ServerMetrics'
literal 'extra' column). 20 purely-mechanical to_dicts across 15 files
convert; genuinely custom shapes keep their hand-written methods (plan
75 §F's ruling stands). Field selection stays api/_query.py's job.
Gate: key-for-key parity against the pre-conversion key sets frozen
from git HEAD (only the Timestamp pair may be additive).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-19 05:33:17 -04:00

25 lines
1.1 KiB
Python

from datetime import datetime
from app import db
from app.models.mixins import SerializableMixin
class ImageUpdateCheck(SerializableMixin, db.Model):
"""Result of comparing an application's running image digest against the
current digest for the same tag in its registry."""
__tablename__ = 'image_update_checks'
id = db.Column(db.Integer, primary_key=True)
application_id = db.Column(db.Integer, db.ForeignKey('applications.id'), nullable=False, index=True)
image_ref = db.Column(db.String(500), nullable=False)
current_digest = db.Column(db.String(128)) # sha256:... running locally
latest_digest = db.Column(db.String(128)) # sha256:... currently in the registry
update_available = db.Column(db.Boolean, default=False, nullable=False)
status = db.Column(db.String(20), default='pending') # pending, completed, failed
error_message = db.Column(db.Text)
checked_at = db.Column(db.DateTime, default=datetime.utcnow)
application = db.relationship('Application', backref=db.backref(
'image_update_checks', lazy='dynamic',
order_by='ImageUpdateCheck.checked_at.desc()'))