-- Simulates the planned mozdit_automation database (ops-automation-phase1 design D3). CREATE DATABASE automation_pilot; \connect automation_pilot CREATE TABLE check_result ( id bigserial PRIMARY KEY, run_id uuid NOT NULL, target text NOT NULL, check_type text NOT NULL, status text NOT NULL CHECK (status IN ('ok','warning','critical','unknown')), "values" jsonb NOT NULL, measured_at timestamptz NOT NULL); CREATE TABLE check_state ( target text, check_type text, status text NOT NULL, since timestamptz NOT NULL, last_alert_at timestamptz, consecutive_failures int NOT NULL DEFAULT 0, PRIMARY KEY (target, check_type)); CREATE TABLE dlq_events ( id bigserial PRIMARY KEY, workflow text NOT NULL, payload jsonb NOT NULL, error text NOT NULL, created_at timestamptz NOT NULL DEFAULT now(), replayed_at timestamptz);