Files
mtusi2026lab5/src/main/resources/db/migration/V2__idempotency.sql
T
2026-11-20 22:48:28 +03:00

14 lines
509 B
SQL

CREATE TABLE message_idempotency (
actor_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
method VARCHAR(10) NOT NULL,
request_path VARCHAR(200) NOT NULL,
idempotency_key VARCHAR(128) NOT NULL,
request_hash CHAR(64) NOT NULL,
message_id UUID REFERENCES messages(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL,
PRIMARY KEY (actor_id, method, request_path, idempotency_key)
);
CREATE INDEX idx_message_idempotency_created
ON message_idempotency(created_at);