mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-11-02 18:17:11 +09:00
An audit found 102 FK columns with no index — every join, per-parent listing, and the delete cascades from _delete_cascade_policy scanned whole tables on them (deployments.app_id, audit_logs.user_id, dns_records.zone_id, webhook_logs.webhook_id, ...). All FK columns now declare index=True; migration 096 creates the same indexes on existing installs, deriving the list from the live schema at upgrade time (so it is idempotent and cannot drift from what an install actually has). Ratchet: test_every_fk_column_is_indexed pins the rule with no allowlist — a new FK column is born indexed or the build fails. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
from datetime import datetime
|
|
|
|
from app import db
|
|
|
|
|
|
class SandboxRun(db.Model):
|
|
"""One Test Sandbox execution: a set of distro containers running the
|
|
installer / script test suites, driven from the Test Sandbox UI.
|
|
|
|
``results`` is a JSON object keyed by distro id:
|
|
``{"ubuntu22": {"status": "passed|failed|running|queued|skipped",
|
|
"detail": "...", "duration_s": 12.3}, ...}``
|
|
Per-distro full logs live on disk under
|
|
``instance/sandbox-runs/<id>/<distro>.log`` (see test_sandbox_service).
|
|
"""
|
|
__tablename__ = 'sandbox_runs'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
mode = db.Column(db.String(16), nullable=False, default='quick') # quick | full
|
|
distros = db.Column(db.JSON) # list of distro keys requested
|
|
# running | done | error | cancelled
|
|
status = db.Column(db.String(16), nullable=False, default='running', index=True)
|
|
results = db.Column(db.JSON)
|
|
error = db.Column(db.Text)
|
|
user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=True, index=True)
|
|
created_at = db.Column(db.DateTime, default=datetime.utcnow, index=True)
|
|
finished_at = db.Column(db.DateTime)
|
|
|
|
def to_dict(self):
|
|
return {
|
|
'id': self.id,
|
|
'mode': self.mode,
|
|
'distros': self.distros or [],
|
|
'status': self.status,
|
|
'results': self.results or {},
|
|
'error': self.error,
|
|
'user_id': self.user_id,
|
|
'created_at': self.created_at.isoformat() if self.created_at else None,
|
|
'finished_at': self.finished_at.isoformat() if self.finished_at else None,
|
|
}
|