forked from mtusi2026/mtusi2026lab4
13 lines
652 B
SQL
13 lines
652 B
SQL
-- 002: общая идемпотентность отправки сообщений
|
|
CREATE TABLE IF NOT EXISTS idempotency_keys (
|
|
user_id uuid NOT NULL REFERENCES users (id),
|
|
method text NOT NULL,
|
|
path text NOT NULL,
|
|
idem_key text NOT NULL,
|
|
request_hash bytea NOT NULL, -- SHA-256 канонического тела
|
|
message_id uuid REFERENCES messages (id),
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
PRIMARY KEY (user_id, method, path, idem_key)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idempotency_created_idx ON idempotency_keys (created_at); |