Skip to main content

max / makenotwork

633 B · 15 lines History Blame Raw
1 -- Item sections: tabbed markdown content blocks within items.
2 CREATE TABLE item_sections (
3 id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
4 item_id UUID NOT NULL REFERENCES items(id) ON DELETE CASCADE,
5 title VARCHAR(100) NOT NULL,
6 slug VARCHAR(120) NOT NULL,
7 body TEXT NOT NULL DEFAULT '',
8 sort_order INTEGER NOT NULL DEFAULT 0,
9 created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
10 updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
11 );
12
13 CREATE UNIQUE INDEX idx_item_sections_item_slug ON item_sections(item_id, slug);
14 CREATE INDEX idx_item_sections_item_order ON item_sections(item_id, sort_order);
15