Files
jlinc-server/backend/db/migrations/000021 - agreement-fetch.sql
2026-08-20 15:08:32 +00:00

16 lines
788 B
SQL

-- Retry bookkeeping for remote agreement-markdown fetches. Kept separate from
-- agreement_content (which is immutable once inserted) because this state is
-- mutable: attempts and the next scheduled try are updated on each failure and
-- the row is deleted once the content is successfully cached.
CREATE TABLE IF NOT EXISTS public.agreement_fetch (
agreement_uuid UUID PRIMARY KEY,
remote_url TEXT NOT NULL,
attempts INTEGER NOT NULL DEFAULT 0,
next_attempt_ts TIMESTAMPTZ NOT NULL DEFAULT NOW(),
last_error TEXT,
created_ts TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_ts TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx__public__agreement_fetch__next_attempt_ts ON public.agreement_fetch (next_attempt_ts);