forked from mtusi2026/mtusi2026lab3
8 lines
354 B
SQL
8 lines
354 B
SQL
CREATE TABLE messages (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
|
|
sender_id UUID NOT NULL REFERENCES users(id) ON DELETE RESTRICT,
|
|
text TEXT NOT NULL CHECK (char_length(text) BETWEEN 1 AND 4000 AND btrim(text) <> ''),
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|