BEGIN; CREATE TABLE platform_health_snapshot ( id bigserial PRIMARY KEY, public_id uuid NOT NULL UNIQUE DEFAULT gen_random_uuid(), schema_name varchar(64) NOT NULL CHECK (schema_name='platform-server-health-v1'), status varchar(16) NOT NULL CHECK (status IN ('healthy','warning','critical')), observed_at timestamptz NOT NULL, received_at timestamptz NOT NULL DEFAULT now(), checks jsonb NOT NULL, body_digest char(64) NOT NULL UNIQUE, CONSTRAINT platform_health_checks_array CHECK (jsonb_typeof(checks)='array') ); CREATE INDEX platform_health_snapshot_observed_idx ON platform_health_snapshot(observed_at DESC, id DESC); COMMIT;