forked from mtusi2026/mtusi2026lab3
12 lines
532 B
SQL
12 lines
532 B
SQL
CREATE TABLE message_requests (
|
|
user_id uuid NOT NULL REFERENCES users(id),
|
|
chat_id uuid NOT NULL REFERENCES chats(id),
|
|
request_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(),
|
|
expires_at timestamptz NOT NULL DEFAULT (clock_timestamp() + interval '24 hours'),
|
|
PRIMARY KEY (user_id, chat_id, request_key)
|
|
);
|
|
CREATE INDEX message_requests_expiry_idx ON message_requests(expires_at);
|