chore(deploy): apply prod DB URL + onboarding-pipeline deploy script
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>main
parent
371cdb1c69
commit
45cfb83d03
@ -0,0 +1,68 @@
|
||||
// One-off deploy step for the Client Detail redesign: overwrite the live onboarding-template
|
||||
// settings with the composed quotation-led pipeline (shared front + per-module tail), then run
|
||||
// the tick-preserving migration so existing SMS/RTGS/MobileApp projects adopt the new steps.
|
||||
// Idempotent. Run from repo root: npx tsx apps/hq/scripts/apply-onboarding-pipeline.ts
|
||||
import { openDb } from '../src/db'
|
||||
import { openPgDb } from '../src/db-pg'
|
||||
import { migrateOnboardingTemplates } from '../src/migrate-onboarding-templates'
|
||||
|
||||
const FRONT = [
|
||||
{ key: 'enquiry', label: 'Enquiry received' },
|
||||
{ key: 'visit_meeting', label: 'Visit / meeting scheduled' },
|
||||
{ key: 'quotation_sent', label: 'Quotation sent' },
|
||||
{ key: 'quotation_approved', label: 'Quotation approved' },
|
||||
]
|
||||
const TAILS: Record<string, { key: string; label: string }[]> = {
|
||||
SMS: [
|
||||
{ key: 'document_collection', label: 'Document collection' },
|
||||
{ key: 'dlt_registration', label: 'DLT registration' },
|
||||
{ key: 'account_creation', label: 'Account creation & registration' },
|
||||
{ key: 'installation', label: 'Installation' },
|
||||
{ key: 'testing', label: 'Testing' },
|
||||
{ key: 'training', label: 'Training' },
|
||||
{ key: 'go_live', label: 'Go-live' },
|
||||
{ key: 'payment_received', label: 'Payment received' },
|
||||
],
|
||||
RTGS: [
|
||||
{ key: 'document_collection', label: 'Document collection' },
|
||||
{ key: 'server_checkup', label: 'Server checkup' },
|
||||
{ key: 'setup_configuration', label: 'Setup & configuration' },
|
||||
{ key: 'installation', label: 'Installation' },
|
||||
{ key: 'testing', label: 'Testing' },
|
||||
{ key: 'training', label: 'Training' },
|
||||
{ key: 'go_live', label: 'Go-live' },
|
||||
{ key: 'payment_received', label: 'Payment received' },
|
||||
],
|
||||
MOBILEAPP: [
|
||||
{ key: 'requirement_setup', label: 'Requirement & setup' },
|
||||
{ key: 'configuration', label: 'Configuration' },
|
||||
{ key: 'data_import', label: 'Data import' },
|
||||
{ key: 'installation', label: 'Installation' },
|
||||
{ key: 'testing', label: 'Testing' },
|
||||
{ key: 'training', label: 'Training' },
|
||||
{ key: 'go_live', label: 'Go-live' },
|
||||
{ key: 'payment_received', label: 'Payment received' },
|
||||
],
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const pgUrl = process.env['DATABASE_URL'] ?? ''
|
||||
const db = pgUrl !== '' ? await openPgDb(pgUrl) : openDb(process.env['HQ_DATA_DIR'])
|
||||
|
||||
const upsert = async (key: string, list: unknown): Promise<void> => {
|
||||
await db.run(
|
||||
`INSERT INTO setting (key, value) VALUES (?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value`,
|
||||
key, JSON.stringify(list),
|
||||
)
|
||||
}
|
||||
await upsert('project.milestone_template.front', FRONT)
|
||||
for (const [code, list] of Object.entries(TAILS)) await upsert(`project.milestone_template:${code}`, list)
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Template settings updated: front + SMS/RTGS/MOBILEAPP tails.')
|
||||
|
||||
const res = await migrateOnboardingTemplates(db)
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Onboarding migration: ${res.projects} project(s) rebuilt, ${res.carried} tick(s) carried, ${res.dropped} dropped.`)
|
||||
}
|
||||
|
||||
main().catch((e) => { console.error(e); process.exit(1) })
|
||||
Loading…
Reference in New Issue