Files
mtusi2026lab3/migrations/002_idempotency.sql
T

11 lines
365 B
SQL

CREATE TABLE message_requests (
sender_id UUID NOT NULL REFERENCES users(id),
chat_id UUID NOT NULL REFERENCES chats(id),
key VARCHAR(128) NOT NULL,
body TEXT NOT NULL,
response JSONB NOT NULL,
expires_at TIMESTAMPTZ NOT NULL,
PRIMARY KEY(sender_id, chat_id, key)
);
CREATE INDEX message_requests_expiry ON message_requests(expires_at);