Files
sori.studio/db/migrations/005_add_navigation_items.sql
2026-05-02 16:45:52 +09:00

30 lines
1.2 KiB
SQL

CREATE TABLE IF NOT EXISTS navigation_items (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
label TEXT NOT NULL,
url TEXT NOT NULL,
location TEXT NOT NULL DEFAULT 'primary',
sort_order INTEGER NOT NULL DEFAULT 0,
is_visible BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
UNIQUE (location, label, url),
CONSTRAINT navigation_items_location_check CHECK (location IN ('primary', 'footer'))
);
CREATE INDEX IF NOT EXISTS navigation_items_location_sort_order_idx
ON navigation_items (location, sort_order ASC, label ASC);
INSERT INTO navigation_items (label, url, location, sort_order, is_visible)
VALUES
('Home pages', '/', 'primary', 10, true),
('Tags', '/tags', 'primary', 20, true),
('Authors', '/pages/about', 'primary', 30, true),
('Style', '/post/hello-sori-studio', 'primary', 40, true),
('Post types', '/post/custom-writing-tool', 'primary', 50, true),
('Members', '/pages/contact', 'primary', 60, true),
('Landing pages', '/pages/projects', 'primary', 70, true),
('Portal', '/pages/links', 'footer', 10, true),
('Docs', '/pages/about', 'footer', 20, true),
('Projects', '/pages/projects', 'footer', 30, true)
ON CONFLICT DO NOTHING;