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 modifiedsnapshot— The complete SLO state after the changediff_type— The operation typeparent_slo_id— Links to the previous version for rollback chains
Indexes
| Index | Purpose |
|---|---|
idx_slo_versions_slo_id | Fast lookup by SLO |
idx_slo_versions_timestamp | Time-ordered history |
idx_slo_versions_created_by | Audit 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