forked from mtusi2026/mtusi2026lab7
11 lines
399 B
SQL
11 lines
399 B
SQL
CREATE TABLE idempotency (
|
|
user_id uuid NOT NULL REFERENCES users(id),
|
|
chat_id uuid NOT NULL REFERENCES chats(id),
|
|
key varchar(128) NOT NULL,
|
|
request jsonb NOT NULL,
|
|
response jsonb NOT NULL,
|
|
expires_at timestamptz NOT NULL DEFAULT (clock_timestamp() + interval '24 hours'),
|
|
PRIMARY KEY (user_id,chat_id,key)
|
|
);
|
|
CREATE INDEX idempotency_expiry ON idempotency(expires_at);
|