Skip to main content

max / multithreaded

462 B · 14 lines History Blame Raw
1 CREATE TABLE categories (
2 id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
3 community_id UUID NOT NULL REFERENCES communities(id) ON DELETE CASCADE,
4 name TEXT NOT NULL,
5 slug TEXT NOT NULL,
6 description TEXT,
7 sort_order INT NOT NULL DEFAULT 0,
8 created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
9
10 UNIQUE (community_id, slug)
11 );
12
13 CREATE INDEX idx_categories_community ON categories (community_id, sort_order);
14