diff --git a/scripts/seed-demo.js b/scripts/seed-demo.js index 8b9733b..dbd9286 100644 --- a/scripts/seed-demo.js +++ b/scripts/seed-demo.js @@ -58,9 +58,9 @@ function kebab(s) { } const newCabs = [ - { name: 'Anna Kjær', email: 'anna@kommune.dk', org: 'Kbh Kommune' }, - { name: 'Søren Vedel', email: 'soren@energinet.dk', org: 'Energinet' }, - { name: 'Henriette Rask',email: 'henriette@dnv.dk', org: 'Dansk Nationalbank' }, + { name: 'Anna Kjær', email: 'anna@virk3.dk', org: 'Virksomhed 3' }, + { name: 'Søren Vedel', email: 'soren@virk4.dk', org: 'Virksomhed 4' }, + { name: 'Henriette Rask',email: 'henriette@virk5.dk',org: 'Virksomhed 5' }, ]; const insertUser = db.prepare(` @@ -75,7 +75,7 @@ for (const c of newCabs) { // We backdate cab_joined_date first, then let allocateMemberNumber pick it up. // Lars: 0 weeks ago (most senior), then 2 / 4 / 6 weeks for the others. const cabRows = db.prepare("SELECT id, email, name FROM users WHERE role = 'cab' AND active = 1 ORDER BY id").all(); -const tenureWeeks = { 'lars@rigspolitiet.dk': 24, 'anna@kommune.dk': 6, 'soren@energinet.dk': 4, 'henriette@dnv.dk': 2 }; +const tenureWeeks = { 'lars@virk2.dk': 24, 'anna@virk3.dk': 6, 'soren@virk4.dk': 4, 'henriette@virk5.dk': 2 }; const setCabMeta = db.prepare(` UPDATE users @@ -88,22 +88,22 @@ const setCabMeta = db.prepare(` `); const cabMeta = { - 'lars@rigspolitiet.dk': { + 'lars@virk2.dk': { title: 'Senior Adviser, Operational Risk', pull_quote: 'A model is only as auditable as the chain of evidence behind it. That chain is the work.', focus_tags: ['Risk', 'Audit trail', 'GDPR'], }, - 'anna@kommune.dk': { + 'anna@virk3.dk': { title: 'Director of Digital Services', pull_quote: 'Municipalities can\'t outsource sovereignty. We need tools that assume that.', focus_tags: ['Public sector', 'Sovereignty'], }, - 'soren@energinet.dk': { + 'soren@virk4.dk': { title: 'Head of Data Engineering', pull_quote: 'Make it boring to deploy and surprising to query.', focus_tags: ['Infrastructure', 'Telemetry'], }, - 'henriette@dnv.dk': { + 'henriette@virk5.dk': { title: 'Lead Counsel, Compliance', pull_quote: 'I\'ve never trusted a system I couldn\'t cross-examine.', focus_tags: ['Legal', 'Policy', 'EU AI Act'], diff --git a/scripts/seed.js b/scripts/seed.js index 9b0cdac..5b0d9f3 100644 --- a/scripts/seed.js +++ b/scripts/seed.js @@ -17,14 +17,22 @@ try { process.exit(1); } -// Wipe existing seed data (idempotent) +// Wipe existing seed data (idempotent). Order matters: every table that +// FK-references users (without ON DELETE CASCADE) must be cleared first. db.exec(` + DELETE FROM activity; + DELETE FROM votes; + DELETE FROM dispatches; + DELETE FROM events; + DELETE FROM pulses; + DELETE FROM roadmap_attributions; DELETE FROM reactions; DELETE FROM replies; DELETE FROM contributions; DELETE FROM attendance; - DELETE FROM sessions; + DELETE FROM join_requests; DELETE FROM invites; + DELETE FROM sessions; DELETE FROM users; `); @@ -32,21 +40,21 @@ const ROUNDS = 10; const users = [ { - email: 'mette@ssi.dk', + email: 'mette@virk1.dk', password: 'pilot123', name: 'Mette Hansen', - organisation: 'Statens Serum Institut', + organisation: 'Virksomhed 1', role: 'pilot', }, { - email: 'lars@rigspolitiet.dk', + email: 'lars@virk2.dk', password: 'cab123', name: 'Lars Thomsen', - organisation: 'Rigspolitiet', + organisation: 'Virksomhed 2', role: 'cab', }, { - email: 'jonathan@fenja.ai', + email: 'jonathan@studio.test', password: 'fenja123', name: 'Jonathan', organisation: 'Fenja AI', @@ -55,14 +63,15 @@ const users = [ ]; const insertUser = db.prepare(` - INSERT INTO users (email, password_hash, name, organisation, role, bio) - VALUES (?, ?, ?, ?, ?, ?) + INSERT INTO users (email, password_hash, name, organisation, role, bio, slug) + VALUES (?, ?, ?, ?, ?, ?, ?) `); const userIds = {}; for (const u of users) { const hash = bcrypt.hashSync(u.password, ROUNDS); - const result = insertUser.run(u.email, hash, u.name, u.organisation, u.role, ''); + const slug = u.name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, ''); + const result = insertUser.run(u.email, hash, u.name, u.organisation, u.role, '', slug); userIds[u.role] = Number(result.lastInsertRowid); console.log(` created user: ${u.name} (${u.role}) — password: ${u.password}`); } @@ -135,7 +144,7 @@ insertAttendance.run(userIds['cab'], '2026-04-25-cab-q2-session', 'no'); console.log('\n Seed complete.'); console.log('\n Test credentials:'); -console.log(' mette@ssi.dk / pilot123 (pilot)'); -console.log(' lars@rigspolitiet.dk / cab123 (cab)'); -console.log(' jonathan@fenja.ai / fenja123 (fenja)'); +console.log(' mette@virk1.dk / pilot123 (pilot)'); +console.log(' lars@virk2.dk / cab123 (cab)'); +console.log(' jonathan@studio.test / fenja123 (fenja)'); db.close();