diff --git a/db/migrations/001_app_records.sql b/db/migrations/001_app_records.sql index 3270d41..9317315 100644 --- a/db/migrations/001_app_records.sql +++ b/db/migrations/001_app_records.sql @@ -1,2 +1,11 @@ --- Replaced by 001_quotejudge_schema.sql. Kept as a no-op so prior scaffold --- migration names remain harmless and idempotent across repair iterations. +CREATE TABLE IF NOT EXISTS app_records ( + id BIGSERIAL PRIMARY KEY, + tenant_key TEXT NOT NULL, + record_kind TEXT NOT NULL, + payload JSONB NOT NULL, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +CREATE INDEX IF NOT EXISTS app_records_tenant_kind_idx + ON app_records (tenant_key, record_kind, created_at DESC);