// apps/hq/scripts/migrate-onboarding-templates.ts — Client Detail redesign task 5: one-time // migration swapping existing SMS/RTGS/MobileApp projects off the old generic onboarding // checklist onto their new per-module template, carrying mapped ticks. Idempotent — safe // to re-run (a second run does nothing). // DATABASE_URL=postgres://… npx tsx apps/hq/scripts/migrate-onboarding-templates.ts import { openDb } from '../src/db' import { openPgDb } from '../src/db-pg' import { migrateOnboardingTemplates } from '../src/migrate-onboarding-templates' async function main() { const pgUrl = process.env['DATABASE_URL'] ?? '' const db = pgUrl !== '' ? await openPgDb(pgUrl) : openDb(process.env['HQ_DATA_DIR']) const res = await migrateOnboardingTemplates(db) // eslint-disable-next-line no-console console.log(`Onboarding template migration: ${res.projects} project(s) rebuilt, ${res.carried} tick(s) carried, ${res.dropped} dropped.`) } main().catch((e) => { console.error(e); process.exit(1) })