Files
mtusi2026lab7/migrations/002_idempotency.sql
T
allerg1q c188a3beca
Skeleton contracts / contracts (pull_request) Blocked by required conditions
feat(lab7): implement secure messenger infrastructure with TLS, OpenBao and observability
2026-11-29 18:06:02 +03:00

15 lines
500 B
SQL

CREATE TABLE IF NOT EXISTS message_idempotency (
user_id UUID NOT NULL REFERENCES users(id),
chat_id UUID NOT NULL REFERENCES chats(id),
idempotency_key VARCHAR(128) NOT NULL,
request_hash CHAR(64) NOT NULL,
message_id UUID NOT NULL REFERENCES messages(id),
created_at TIMESTAMPTZ NOT NULL DEFAULT clock_timestamp(),
PRIMARY KEY (user_id, chat_id, idempotency_key)
);
CREATE INDEX IF NOT EXISTS idx_idempotency_created
ON message_idempotency(created_at);