server/migrations/seed_dev.sql
vegard 7e83292abe Notater: auto-save scratchpad med debounce
- Migrering 0004: notes-tabell (nodes i kunnskapsgrafen)
- REST API: GET/PATCH notat
- PG-adapter med 500ms debounce og 10s polling
- NotesBlock: tittel + fritekst med auto-lagring og status
- Seed: notater for begge workspaces, kalenderside med 2-1 layout

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 03:03:41 +01:00

187 lines
8.9 KiB
PL/PgSQL

-- Utviklingsdata for lokalt testmiljø.
-- Kjøres etter 0001_initial_schema.sql.
-- IKKE bruk i produksjon.
BEGIN;
-- Test-workspace
INSERT INTO workspaces (id, name, slug) VALUES
('a0000000-0000-0000-0000-000000000001', 'Sidelinja Podcast', 'sidelinja');
-- Vegard (Authentik sub claim + dev-user alias)
INSERT INTO users (authentik_id, display_name) VALUES
('6af61f43c6647a237cbb381ee7788376a9bc20299c2c06281d9954d763e854f0', 'Vegard Nøtnæs'),
('dev-user-1', 'Vegard (dev)');
-- Koble begge bruker-IDer til workspace
INSERT INTO workspace_members (workspace_id, user_id, role) VALUES
('a0000000-0000-0000-0000-000000000001', '6af61f43c6647a237cbb381ee7788376a9bc20299c2c06281d9954d763e854f0', 'owner'),
('a0000000-0000-0000-0000-000000000001', 'dev-user-1', 'owner');
-- Workspace-rot-node (parent for workspace-level channels)
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('a0000000-0000-0000-0000-000000000010', 'a0000000-0000-0000-0000-000000000001', 'channel');
-- Generell chat-kanal
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('a0000000-0000-0000-0000-000000000011', 'a0000000-0000-0000-0000-000000000001', 'channel');
INSERT INTO channels (id, parent_id, name) VALUES
('a0000000-0000-0000-0000-000000000011', 'a0000000-0000-0000-0000-000000000010', 'Generelt');
-- Redaksjons-kanal
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('a0000000-0000-0000-0000-000000000012', 'a0000000-0000-0000-0000-000000000001', 'channel');
INSERT INTO channels (id, parent_id, name) VALUES
('a0000000-0000-0000-0000-000000000012', 'a0000000-0000-0000-0000-000000000010', 'Redaksjonen');
-- =============================================
-- Workspace 2: Foreningen Liberalistene
-- =============================================
INSERT INTO workspaces (id, name, slug) VALUES
('b0000000-0000-0000-0000-000000000001', 'Foreningen Liberalistene', 'forlib');
-- Vegard er medlem av begge workspaces
INSERT INTO workspace_members (workspace_id, user_id, role) VALUES
('b0000000-0000-0000-0000-000000000001', '6af61f43c6647a237cbb381ee7788376a9bc20299c2c06281d9954d763e854f0', 'owner'),
('b0000000-0000-0000-0000-000000000001', 'dev-user-1', 'owner');
-- Rot-node for Liberalistene
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('b0000000-0000-0000-0000-000000000010', 'b0000000-0000-0000-0000-000000000001', 'channel');
-- Chat-kanaler
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('b0000000-0000-0000-0000-000000000011', 'b0000000-0000-0000-0000-000000000001', 'channel');
INSERT INTO channels (id, parent_id, name) VALUES
('b0000000-0000-0000-0000-000000000011', 'b0000000-0000-0000-0000-000000000010', 'Generelt');
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('b0000000-0000-0000-0000-000000000012', 'b0000000-0000-0000-0000-000000000001', 'channel');
INSERT INTO channels (id, parent_id, name) VALUES
('b0000000-0000-0000-0000-000000000012', 'b0000000-0000-0000-0000-000000000010', 'Styret');
-- Kalender for Liberalistene
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('b0000000-0000-0000-0000-000000000030', 'b0000000-0000-0000-0000-000000000001', 'calendar');
INSERT INTO calendars (id, parent_id, name, color) VALUES
('b0000000-0000-0000-0000-000000000030', 'b0000000-0000-0000-0000-000000000010', 'Foreningskalender', '#f59e0b');
-- Notat for Liberalistene
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('b0000000-0000-0000-0000-000000000040', 'b0000000-0000-0000-0000-000000000001', 'note');
INSERT INTO notes (id, parent_id, title, content) VALUES
('b0000000-0000-0000-0000-000000000040', 'b0000000-0000-0000-0000-000000000010', 'Møtenotater', '');
-- Kanban-brett for Liberalistene
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('b0000000-0000-0000-0000-000000000020', 'b0000000-0000-0000-0000-000000000001', 'kanban_board');
INSERT INTO kanban_boards (id, parent_id, name) VALUES
('b0000000-0000-0000-0000-000000000020', 'b0000000-0000-0000-0000-000000000010', 'Oppgaver');
INSERT INTO kanban_columns (id, board_id, name, color, position) VALUES
('b0000000-0000-0000-0000-000000000021', 'b0000000-0000-0000-0000-000000000020', 'Å gjøre', '#8b92a5', 1),
('b0000000-0000-0000-0000-000000000022', 'b0000000-0000-0000-0000-000000000020', 'Pågår', '#f59e0b', 2),
('b0000000-0000-0000-0000-000000000023', 'b0000000-0000-0000-0000-000000000020', 'Ferdig', '#10b981', 3);
-- Sider for Liberalistene
UPDATE workspaces SET settings = jsonb_set(
COALESCE(settings, '{}'::jsonb),
'{pages}',
'[
{
"slug": "styrearbeid",
"title": "Styrearbeid",
"icon": "🏛️",
"layout": "2-1",
"blocks": [
{"id": "chat-lib-1", "type": "chat", "title": "Styrechat", "props": {"channelId": "b0000000-0000-0000-0000-000000000012"}},
{"id": "kanban-lib-1", "type": "kanban", "title": "Oppgaver", "props": {"boardId": "b0000000-0000-0000-0000-000000000020"}}
]
},
{
"slug": "kalender",
"title": "Kalender",
"icon": "📅",
"layout": "2-1",
"blocks": [
{"id": "cal-lib-1", "type": "calendar", "title": "Foreningskalender", "props": {"calendarId": "b0000000-0000-0000-0000-000000000030"}},
{"id": "notes-lib-1", "type": "notes", "title": "Møtenotater", "props": {"noteId": "b0000000-0000-0000-0000-000000000040"}}
]
},
{
"slug": "generelt",
"title": "Generelt",
"icon": "💬",
"layout": "single",
"blocks": [
{"id": "chat-lib-2", "type": "chat", "title": "Generell diskusjon", "props": {"channelId": "b0000000-0000-0000-0000-000000000011"}}
]
}
]'::jsonb
) WHERE slug = 'forlib';
-- =============================================
-- Sidelinja: Kanban-brett for redaksjonen
-- =============================================
-- Kalender for Sidelinja
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('a0000000-0000-0000-0000-000000000030', 'a0000000-0000-0000-0000-000000000001', 'calendar');
INSERT INTO calendars (id, parent_id, name, color) VALUES
('a0000000-0000-0000-0000-000000000030', 'a0000000-0000-0000-0000-000000000010', 'Redaksjonskalender', '#3b82f6');
-- Notat for Sidelinja
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('a0000000-0000-0000-0000-000000000040', 'a0000000-0000-0000-0000-000000000001', 'note');
INSERT INTO notes (id, parent_id, title, content) VALUES
('a0000000-0000-0000-0000-000000000040', 'a0000000-0000-0000-0000-000000000010', 'Show notes', '');
-- Kanban-brett for redaksjonen
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('a0000000-0000-0000-0000-000000000020', 'a0000000-0000-0000-0000-000000000001', 'kanban_board');
INSERT INTO kanban_boards (id, parent_id, name) VALUES
('a0000000-0000-0000-0000-000000000020', 'a0000000-0000-0000-0000-000000000010', 'Episodeplanlegging');
INSERT INTO kanban_columns (id, board_id, name, color, position) VALUES
('a0000000-0000-0000-0000-000000000021', 'a0000000-0000-0000-0000-000000000020', 'Ideer', '#8b92a5', 1),
('a0000000-0000-0000-0000-000000000022', 'a0000000-0000-0000-0000-000000000020', 'Planlagt', '#f59e0b', 2),
('a0000000-0000-0000-0000-000000000023', 'a0000000-0000-0000-0000-000000000020', 'Innspilt', '#3b82f6', 3),
('a0000000-0000-0000-0000-000000000024', 'a0000000-0000-0000-0000-000000000020', 'Publisert', '#10b981', 4);
-- Default-sider for workspace
UPDATE workspaces SET settings = jsonb_set(
COALESCE(settings, '{}'::jsonb),
'{pages}',
'[
{
"slug": "redaksjonen",
"title": "Redaksjonen",
"icon": "📰",
"layout": "2-1",
"blocks": [
{"id": "chat-1", "type": "chat", "title": "Redaksjonschat", "props": {"channelId": "a0000000-0000-0000-0000-000000000012"}},
{"id": "kanban-1", "type": "kanban", "title": "Planlegging", "props": {"boardId": "a0000000-0000-0000-0000-000000000020"}}
]
},
{
"slug": "kalender",
"title": "Kalender",
"icon": "📅",
"layout": "2-1",
"blocks": [
{"id": "cal-1", "type": "calendar", "title": "Redaksjonskalender", "props": {"calendarId": "a0000000-0000-0000-0000-000000000030"}},
{"id": "notes-1", "type": "notes", "title": "Show notes", "props": {"noteId": "a0000000-0000-0000-0000-000000000040"}}
]
},
{
"slug": "research",
"title": "Research",
"icon": "🔍",
"layout": "2-col",
"blocks": [
{"id": "research-1", "type": "research", "title": "Research-klipp"},
{"id": "graph-1", "type": "graph", "title": "Kunnskapsgraf"}
]
}
]'::jsonb
) WHERE slug = 'sidelinja';
COMMIT;