Files
mtusi2026lab2/student-tests/fixtures/legacy/0002_idempotency_keys.sql
T
Artyom 8e4532f6f5 Forward-port lab3 SQLAlchemy and Alembic foundation
Carry source f591fa64e5 forward from 72a1e57. Preserve lab4 attachment transactions, reconciliation locks, quarantine, and existing schema data through verified legacy adoption. Keep report and evidence work in progress untouched.
2026-11-06 01:47:30 +03:00

11 lines
453 B
SQL

CREATE TABLE idempotency_keys (
chat_id uuid NOT NULL,
user_id uuid NOT NULL,
key text NOT NULL CHECK (key ~ '^[A-Za-z0-9._:-]{1,128}$'),
fingerprint bytea NOT NULL CHECK (octet_length(fingerprint) = 32),
message_id uuid NOT NULL REFERENCES messages (id) ON DELETE CASCADE,
created_at timestamptz NOT NULL,
PRIMARY KEY (chat_id, user_id, key),
FOREIGN KEY (chat_id, user_id) REFERENCES chat_members (chat_id, user_id)
);