Files
mtusi2026lab6/migrations/003_idempotency.sql
T
2026-11-05 21:17:50 +03:00

13 lines
497 B
SQL

CREATE TABLE idempotency_records (
user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
method varchar(8) NOT NULL,
path text NOT NULL,
idempotency_key varchar(128) NOT NULL,
request_hash char(64) NOT NULL,
message_id uuid REFERENCES messages(id) ON DELETE RESTRICT,
created_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (user_id, method, path, idempotency_key)
);
CREATE INDEX idempotency_records_created_at_idx ON idempotency_records (created_at);