-- ═══════════════════════════════════════════════════════════════ -- 055 THE ORGANIZATION PAGE'S OWN EDITOR, NAMED PATH ICONS -- -- The Organization page (/organization) is edited in the admin like -- the Community blog section (Pages → Organization page): a -- singleton row, organization_page, with -- -- mission blocks content_blocks owned 'org_page_mission': -- the Mission, Vision & Values section -- leadership blocks content_blocks owned 'org_page_leadership': -- the Leadership section, eg. a heading and a -- People block per team (Board of Trustees, -- then the Retreat Team), in the order given -- volunteering a title, a blurb and organization_page_links, -- under the leadership -- -- Two owner kinds rather than a slot, so each list is its own -- collection in the editor. The owner_kind CHECK changes, so -- content_blocks is rebuilt as 054 did, with its index and owner -- trigger (which learns the new kinds) again. -- -- And the front page's "Find your way in" paths: the baseline seeded -- them with emoji, from before the named icon list -- (src/data/pathIcons.ts). The site now draws only named icons, so -- the seeded emoji become their names and any other non-name is -- cleared (shown as a plain dot until one is picked). -- ═══════════════════════════════════════════════════════════════ CREATE TABLE organization_page ( id TEXT PRIMARY KEY CHECK (id = 'organization'), mission_title TEXT, -- null → 'Mission, Vision & Values' leadership_title TEXT, -- null → 'Leadership' leadership_blurb TEXT, volunteer_title TEXT, -- null → 'Volunteering' volunteer_blurb TEXT, updated_at TEXT NOT NULL DEFAULT (datetime('now')) ) STRICT; INSERT INTO organization_page (id) VALUES ('organization'); CREATE TABLE organization_page_links ( id INTEGER PRIMARY KEY AUTOINCREMENT, page_id TEXT NOT NULL REFERENCES organization_page (id) ON DELETE CASCADE, sort_order INTEGER NOT NULL DEFAULT 0, label TEXT NOT NULL, url TEXT NOT NULL ) STRICT; CREATE INDEX organization_page_links_idx ON organization_page_links (page_id, sort_order); -- ── Blocks for the page ──────────────────────────────────────── CREATE TABLE content_blocks_new ( id INTEGER PRIMARY KEY AUTOINCREMENT, owner_kind TEXT NOT NULL CHECK (owner_kind IN ('organization', 'event', 'person', 'team', 'blog_post', 'org_page_mission', 'org_page_leadership')), owner_id TEXT NOT NULL, slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body')), sort_order INTEGER NOT NULL DEFAULT 0, type TEXT NOT NULL CHECK (type IN ('heading', 'subheading', 'paragraph', 'list', 'links', 'quote', 'image', 'divider', 'video', 'button', 'callout', 'schedule', 'table', 'cards', 'people')), text TEXT, media TEXT, href TEXT, alt TEXT, cite TEXT, team_id TEXT REFERENCES teams (id) ON DELETE SET NULL ) STRICT; INSERT INTO content_blocks_new (id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id) SELECT id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id FROM content_blocks; PRAGMA legacy_alter_table = ON; DROP TABLE content_blocks; ALTER TABLE content_blocks_new RENAME TO content_blocks; PRAGMA legacy_alter_table = OFF; CREATE INDEX content_blocks_owner_idx ON content_blocks (owner_kind, owner_id, slot, sort_order); -- ── Path icons ───────────────────────────────────────────────── UPDATE front_page_paths SET icon = 'compass' WHERE icon = '🧭'; UPDATE front_page_paths SET icon = 'hands' WHERE icon = '🤲'; UPDATE front_page_paths SET icon = 'sparkle' WHERE icon = '🌱'; UPDATE front_page_paths SET icon = 'people' WHERE icon = '🤝'; UPDATE front_page_paths SET icon = NULL WHERE icon IS NOT NULL AND icon NOT IN ('heart', 'hands', 'people', 'calendar', 'tent', 'map', 'home', 'book', 'learn', 'chat', 'music', 'compass', 'sparkle', 'star'); -- ── Triggers last (see CLAUDE.md, Migrations) ── CREATE TRIGGER organization_page_touch AFTER UPDATE ON organization_page FOR EACH ROW WHEN new.updated_at = old.updated_at BEGIN UPDATE organization_page SET updated_at = datetime('now') WHERE id = new.id; END; CREATE TRIGGER content_blocks_owner_exists BEFORE INSERT ON content_blocks BEGIN SELECT CASE WHEN new.owner_kind = 'event' AND NOT EXISTS (SELECT 1 FROM events WHERE id = new.owner_id) THEN RAISE(ABORT, 'content_blocks: no such event') WHEN new.owner_kind = 'organization' AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.owner_id) THEN RAISE(ABORT, 'content_blocks: no such organization') WHEN new.owner_kind = 'person' AND NOT EXISTS (SELECT 1 FROM people WHERE id = new.owner_id) THEN RAISE(ABORT, 'content_blocks: no such person') WHEN new.owner_kind = 'team' AND NOT EXISTS (SELECT 1 FROM teams WHERE id = new.owner_id) THEN RAISE(ABORT, 'content_blocks: no such team') WHEN new.owner_kind = 'blog_post' AND NOT EXISTS (SELECT 1 FROM blog_posts WHERE id = new.owner_id) THEN RAISE(ABORT, 'content_blocks: no such blog post') WHEN new.owner_kind IN ('org_page_mission', 'org_page_leadership') AND NOT EXISTS (SELECT 1 FROM organization_page WHERE id = new.owner_id) THEN RAISE(ABORT, 'content_blocks: no such organization page') END; END;