Add music store seed preset and repair data reset script

- music-store-seed.ts: 52 templates covering strings, brass, woodwinds,
  guitar, plus music-specific tickets and a school band batch
- reset-repairs.ts: clears all repair data for switching between presets
- New scripts: bun run db:seed-music, bun run db:seed-reset-repairs
This commit is contained in:
Ryan Moon
2026-03-30 08:52:09 -05:00
parent 701e15ea6d
commit 7176c1471e
2 changed files with 209 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
/**
* Reset repair data — clears all repair tickets, batches, templates, notes, and line items.
* Run: bun run db:seed-reset-repairs
*
* Use this before switching between seed presets (e.g. generic → music store).
*/
import postgres from 'postgres'
const DB_URL = process.env.DATABASE_URL ?? 'postgresql://lunarfront:lunarfront@localhost:5432/lunarfront'
const sql = postgres(DB_URL)
async function reset() {
console.log('Resetting repair data...')
const notes = await sql`DELETE FROM repair_note RETURNING id`
console.log(` Deleted ${notes.length} notes`)
const lineItems = await sql`DELETE FROM repair_line_item RETURNING id`
console.log(` Deleted ${lineItems.length} line items`)
const tickets = await sql`DELETE FROM repair_ticket RETURNING id`
console.log(` Deleted ${tickets.length} tickets`)
const batches = await sql`DELETE FROM repair_batch RETURNING id`
console.log(` Deleted ${batches.length} batches`)
const templates = await sql`DELETE FROM repair_service_template RETURNING id`
console.log(` Deleted ${templates.length} templates`)
console.log('\nRepair data cleared. Run a seed to repopulate.')
await sql.end()
}
reset().catch((err) => {
console.error('Reset failed:', err)
process.exit(1)
})