Files
mtusi2026lab2/service/migrations/004_create_chats_table.sql
T
2026-11-05 14:24:40 +03:00

15 lines
378 B
SQL

CREATE TABLE IF NOT EXISTS chats
(
id UUID PRIMARY KEY,
title VARCHAR(100) NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT chats_title_not_blank CHECK (title !~ '^[[:space:]]*$')
);
CREATE INDEX IF NOT EXISTS idx_chats_created_at_id ON chats (created_at, id);
---- create above / drop below ----
DROP TABLE IF EXISTS chats;