Files
mtusi2026lab4-implementation/internal/repository/postgres/migrations/000002_message_idempotency.up.sql
T

10 lines
447 B
SQL

CREATE TABLE message_idempotency (
user_id uuid NOT NULL REFERENCES users (id),
chat_id uuid NOT NULL REFERENCES chats (id) ON DELETE CASCADE,
key text NOT NULL,
request_hash text NOT NULL,
message_id uuid NOT NULL REFERENCES messages (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
created_at timestamptz NOT NULL,
PRIMARY KEY (user_id, chat_id, key)
);