10 lines
405 B
SQL
10 lines
405 B
SQL
CREATE TABLE message_idempotency (
|
|
user_id uuid NOT NULL REFERENCES users(id),
|
|
method text NOT NULL,
|
|
chat_id uuid NOT NULL REFERENCES chats(id),
|
|
key text NOT NULL CHECK (key COLLATE "C" ~ '^[A-Za-z0-9._:-]{1,128}$'),
|
|
message_id uuid NOT NULL REFERENCES messages(id) DEFERRABLE INITIALLY DEFERRED,
|
|
expires_at timestamptz NOT NULL,
|
|
PRIMARY KEY (user_id, method, chat_id, key)
|
|
);
|