server/migrations/seed_dev.sql
vegard 6edd1fa091 Frontend: entiteter, graf-visualisering og #-autocomplete
- EntitiesBlock: liste med søk/filter, opprett, rediger, slett,
  relasjonsvisning med navigering mellom entiteter
- GraphBlock: SVG force-directed layout via traverse API,
  pan/zoom, drag noder, dobbeltklikk for å utforske
- EntityAutocomplete: #-mention med debounced søk, tastaturnavigering,
  dropdown med typefarger og aliaser
- Registrert entities block-type + kunnskapsgraf-side i seed

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

218 lines
11 KiB
PL/PgSQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Utviklingsdata for lokalt testmiljø.
-- Kjøres etter ALLE migrasjoner (00010005).
-- 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 (meldingsboks)
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('b0000000-0000-0000-0000-000000000040', 'b0000000-0000-0000-0000-000000000001', 'melding');
INSERT INTO messages (id, author_id, message_type, title, body) VALUES
('b0000000-0000-0000-0000-000000000040', 'dev-user-1', 'text', '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 (meldingsboks)
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('a0000000-0000-0000-0000-000000000040', 'a0000000-0000-0000-0000-000000000001', 'melding');
INSERT INTO messages (id, author_id, message_type, title, body) VALUES
('a0000000-0000-0000-0000-000000000040', 'dev-user-1', 'text', 'Show notes', '');
-- =============================================
-- Entiteter for Sidelinja (kunnskapsgraf testdata)
-- =============================================
INSERT INTO nodes (id, workspace_id, node_type) VALUES
('a0000000-0000-0000-0000-000000000050', 'a0000000-0000-0000-0000-000000000001', 'entitet'),
('a0000000-0000-0000-0000-000000000051', 'a0000000-0000-0000-0000-000000000001', 'entitet'),
('a0000000-0000-0000-0000-000000000052', 'a0000000-0000-0000-0000-000000000001', 'entitet'),
('a0000000-0000-0000-0000-000000000053', 'a0000000-0000-0000-0000-000000000001', 'entitet'),
('a0000000-0000-0000-0000-000000000054', 'a0000000-0000-0000-0000-000000000001', 'entitet');
INSERT INTO entities (id, name, type, aliases) VALUES
('a0000000-0000-0000-0000-000000000050', 'Jonas Gahr Støre', 'person', ARRAY['JGS', 'Støre']),
('a0000000-0000-0000-0000-000000000051', 'Arbeiderpartiet', 'organisasjon', ARRAY['AP', 'Ap', 'DNA']),
('a0000000-0000-0000-0000-000000000052', 'Skolepolitikk', 'tema', ARRAY[]::text[]),
('a0000000-0000-0000-0000-000000000053', 'Lørenskog', 'sted', ARRAY['Lørenskog kommune']),
('a0000000-0000-0000-0000-000000000054', 'Hans Petter Sjøli', 'person', ARRAY['Sjøli']);
-- Test-edges (graf-relasjoner)
INSERT INTO graph_edges (workspace_id, source_id, target_id, relation_type, origin) VALUES
('a0000000-0000-0000-0000-000000000001', 'a0000000-0000-0000-0000-000000000050', 'a0000000-0000-0000-0000-000000000051', 'WORKS_FOR', 'user'),
('a0000000-0000-0000-0000-000000000001', 'a0000000-0000-0000-0000-000000000053', 'a0000000-0000-0000-0000-000000000052', 'PART_OF', 'user');
-- 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": "kunnskapsgraf",
"title": "Kunnskapsgraf",
"icon": "🕸️",
"layout": "2-1",
"blocks": [
{"id": "graph-1", "type": "graph", "title": "Grafvisning"},
{"id": "entities-1", "type": "entities", "title": "Entiteter"}
]
},
{
"slug": "research",
"title": "Research",
"icon": "🔍",
"layout": "2-col",
"blocks": [
{"id": "research-1", "type": "research", "title": "Research-klipp"},
{"id": "entities-2", "type": "entities", "title": "Entiteter"}
]
}
]'::jsonb
) WHERE slug = 'sidelinja';
COMMIT;