Files
pn-new-crm/src/lib/db/seed.ts
Matt Ciaccio 4592789712 feat(seed): synthetic fixture covering every pipeline stage + db:reset
Splits seed bootstrap (ports/roles/profile) into a shared module so
two seed entry points can share it:
- pnpm db:seed             realistic NocoDB-shaped fixture (existing)
- pnpm db:seed:synthetic   12 clients, one per pipeline stage + archive
                           variants (rich metadata for restore wizard)

scripts/db-reset.ts truncates all data tables (preserves migrations);
guarded by --confirm and a localhost host check. Companion npm scripts:
- pnpm db:reset
- pnpm db:reseed:realistic
- pnpm db:reseed:synthetic

scripts/dev-open-browser.ts launches a headed Chromium with no viewport
override (uses the host monitor's natural size), pre-fills the login
form for the requested role.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 20:19:50 +02:00

56 lines
1.8 KiB
TypeScript

/**
* Realistic seed (the "production-shaped" fixture).
*
* Bootstraps ports + roles + super-admin profile, then runs
* `seedPortData()` per port to load the NocoDB-shaped multi-cardinality
* fixture (117 berths, 8 clients, 3 companies, 12 yachts, 15 interests,
* 8 reservations).
*
* For a focused test fixture covering every pipeline stage + archive
* variants, use `pnpm db:seed:synthetic` instead.
*
* Run with: pnpm db:seed
*/
import 'dotenv/config';
import { seedBootstrap } from './seed-bootstrap';
import { seedPortData, type SeedSummary } from './seed-data';
async function seed() {
console.log('Seeding Port Nimara CRM (realistic fixture)...');
const portIds = await seedBootstrap();
console.log('');
console.log('Seeding per-port fixtures...');
const summaries: Array<{ name: string; summary: SeedSummary | null }> = [];
for (const p of portIds) {
console.log(` [${p.slug}] seeding fixture data...`);
const summary = await seedPortData(p.id, p.slug);
summaries.push({ name: p.name, summary });
}
console.log('');
console.log('─── Summary ───────────────────────────────────────────────');
for (const s of summaries) {
if (s.summary === null) {
console.log(` ✓ Port "${s.name}" - already seeded (skipped)`);
} else {
const x = s.summary;
console.log(
` ✓ Port "${s.name}" - ${x.berths} berths, ${x.clients} clients, ${x.companies} companies, ${x.yachts} yachts, ${x.interests} interests, ${x.reservations} reservations`,
);
}
}
console.log('');
console.log('Seed complete!');
process.exit(0);
}
seed().catch((err) => {
console.error('Seed failed:', err);
process.exit(1);
});