Files
mtusi2026lab3/src/migrations/002_idempotency.sql
T

11 lines
410 B
SQL

CREATE TABLE message_requests (
user_id uuid NOT NULL,
chat_id uuid NOT NULL,
request_key text NOT NULL,
fingerprint bytea NOT NULL,
expires_at timestamptz NOT NULL DEFAULT (clock_timestamp() + interval '24 hours'),
message_id uuid REFERENCES messages(id),
PRIMARY KEY (user_id, chat_id, request_key),
FOREIGN KEY (chat_id, user_id) REFERENCES chat_members(chat_id, user_id)
);