Files
mtusi2026lab4/migrations/002_idempotency.up.sql

10 lines
381 B
SQL

CREATE TABLE IF NOT EXISTS message_idempotency (
sender_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
idem_key VARCHAR(128) NOT NULL,
text TEXT NOT NULL,
message_id UUID NOT NULL UNIQUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
PRIMARY KEY (sender_id, chat_id, idem_key)
);