chore(seed): fake email domains + extend wipe chain

Swaps real-looking organisation domains in seed fixtures for the
virkN.dk placeholder pattern, so demos and screenshots can't be misread
as implying real-world relationships with the originals.

- mette@ssi.dkmette@virk1.dk
- lars@rigspolitiet.dklars@virk2.dk
- jonathan@fenja.aijonathan@studio.test (separate fake domain for the
  team account, kept distinct from the council virkN namespace)
- anna@kommune.dkanna@virk3.dk
- soren@energinet.dksoren@virk4.dk
- henriette@dnv.dkhenriette@virk5.dk

Organisation strings get the same treatment ('Virksomhed 1' …).

Also fixes two latent bugs surfaced while re-seeding:
- seed.js's INSERT didn't populate the slug column added in migration
  0003. After a re-seed the three base users had NULL slugs. Add a
  kebab-from-name fallback in the INSERT so slugs round-trip.
- seed.js's DELETE chain pre-dated the Phase 1/2 schema additions and
  failed FK constraints (pulses/dispatches/events/votes/activity/
  join_requests/roadmap_attributions). Extend the wipe order so all
  user-referencing tables clear before users.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Hvid 2026-05-11 17:12:47 +02:00
parent 3240e0f052
commit 6b30593abb
2 changed files with 30 additions and 21 deletions

View file

@ -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'],

View file

@ -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();