forked from mtusi2026/mtusi2026lab3
11 lines
438 B
SQL
11 lines
438 B
SQL
CREATE TABLE message_keys (
|
|
user_id uuid NOT NULL REFERENCES users(id),
|
|
chat_id uuid NOT NULL REFERENCES chats(id),
|
|
key text NOT NULL CHECK (key ~ '^[A-Za-z0-9._:-]{1,128}$'),
|
|
text text NOT NULL,
|
|
message_id uuid NOT NULL REFERENCES messages(id) DEFERRABLE INITIALLY DEFERRED,
|
|
expires_at timestamptz NOT NULL,
|
|
PRIMARY KEY (user_id, chat_id, key)
|
|
);
|
|
CREATE INDEX message_keys_expiry ON message_keys(expires_at);
|