before level 3 initial commit

This commit is contained in:
2026-11-05 17:03:42 +03:00
parent 0ab3a341aa
commit 8cd25e448f
32 changed files with 1616 additions and 4 deletions
+16
View File
@@ -0,0 +1,16 @@
-- Result of POST /chats/{id}/messages per (user, method, path, Idempotency-Key).
-- The row and the message are written in one transaction, so a failed attempt leaves no key behind.
CREATE TABLE idempotency_keys (
user_id UUID NOT NULL REFERENCES users (id),
method TEXT NOT NULL,
path TEXT NOT NULL,
key TEXT NOT NULL,
request_hash TEXT NOT NULL,
status_code INTEGER NOT NULL,
response JSONB NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT clock_timestamp(),
PRIMARY KEY (user_id, method, path, key),
CONSTRAINT idempotency_keys_key_format CHECK (key ~ '^[A-Za-z0-9._:-]{1,128}$')
);
CREATE INDEX idempotency_keys_created_idx ON idempotency_keys (created_at);