Files
mtusi2026lab4/migrations/002_idempotency.sql
T

13 lines
556 B
SQL

-- Additive migration: old lab2 tables and rows are unchanged.
-- This table is only for POST /chats/{chat_id}/messages; method/path scope is implicit.
CREATE TABLE message_requests (
actor_id uuid NOT NULL REFERENCES users(id),
chat_id uuid NOT NULL REFERENCES chats(id),
key text NOT NULL CHECK (key ~ '^[A-Za-z0-9._:-]{1,128}$'),
fingerprint text NOT NULL,
response jsonb NOT NULL,
expires_at timestamptz NOT NULL,
PRIMARY KEY (actor_id, chat_id, key)
);
CREATE INDEX message_requests_expiry ON message_requests(expires_at);