Files
mtusi2026lab4-fork/migrations/0002_idempotency.sql
T

15 lines
632 B
SQL

-- Additive migration: compatible with the lab2 schema and existing messages.
CREATE TABLE IF NOT EXISTS message_idempotency (
user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
method text NOT NULL,
path text NOT NULL,
key text NOT NULL,
request_hash text NOT NULL,
response_status integer NOT NULL,
response_body jsonb NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (user_id, method, path, key)
);
-- Results are retained indefinitely in this lab (therefore at least 24 hours).
-- There is intentionally no independent cache expiry that could allow duplicates.