Skip to content

SLO Versioning

SLOzy tracks all changes to SLOs through the slo_versions table (migrations/000005).

Schema

sql
CREATE TABLE slo_versions (
    id SERIAL PRIMARY KEY,
    slo_id INT NOT NULL REFERENCES slos(id) ON DELETE CASCADE,
    parent_slo_id INT REFERENCES slos(id) ON DELETE SET NULL,
    diff_type VARCHAR(20) NOT NULL CHECK (diff_type IN ('create', 'update', 'delete')),
    changes JSONB NOT NULL,     -- JSON patch of what changed
    snapshot JSONB NOT NULL,    -- Full SLO snapshot at time of change
    created_at TIMESTAMPTZ DEFAULT NOW(),
    created_by INT
);

How It Works

Every SLO mutation (create, update, delete) records:

  • changes — A JSON diff showing only the fields that were modified
  • snapshot — The complete SLO state after the change
  • diff_type — The operation type
  • parent_slo_id — Links to the previous version for rollback chains

Indexes

IndexPurpose
idx_slo_versions_slo_idFast lookup by SLO
idx_slo_versions_timestampTime-ordered history
idx_slo_versions_created_byAudit by user

Use Cases

  • Audit trail — Track who changed what and when
  • Rollback — Restore a previous snapshot for recovery
  • Compliance — Maintain history for SLA reporting and audits
  • Diff review — Compare changes between versions via the JSON patch