forked from mtusi2026/mtusi2026lab4
11 lines
405 B
SQL
11 lines
405 B
SQL
CREATE TABLE message_idempotency (
|
|
user_id uuid NOT NULL REFERENCES users(id),
|
|
chat_id uuid NOT NULL REFERENCES chats(id),
|
|
key varchar(128) NOT NULL,
|
|
body_hash bytea NOT NULL,
|
|
message_id uuid UNIQUE REFERENCES messages(id),
|
|
expires_at timestamptz NOT NULL,
|
|
PRIMARY KEY (user_id, chat_id, key)
|
|
);
|
|
CREATE INDEX message_idempotency_expiry_idx ON message_idempotency (expires_at);
|