Files
mtusi2026lab6/internal/database/migrations/002_message_idempotency.sql

14 lines
495 B
SQL

CREATE TABLE message_idempotency (
user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
method text NOT NULL,
path text NOT NULL,
idempotency_key text NOT NULL,
request_hash bytea NOT NULL,
message_id uuid REFERENCES messages(id) ON DELETE CASCADE,
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
PRIMARY KEY (user_id, method, path, idempotency_key)
);
CREATE INDEX message_idempotency_created_at_idx
ON message_idempotency (created_at);