Spaces:
Running
Running
| import Database from 'better-sqlite3'; | |
| import { drizzle } from 'drizzle-orm/better-sqlite3'; | |
| import { BRANCH_MAPPING } from '@icc/shared'; | |
| import { branchConfig } from './schema.js'; | |
| const sqlite = new Database(process.env.DATABASE_URL || 'sqlite.db'); | |
| const db = drizzle(sqlite); | |
| async function seed() { | |
| console.log('Seeding branch configuration...'); | |
| const entries = Object.entries(BRANCH_MAPPING).map(([email, branch]) => ({ | |
| email, | |
| branch, | |
| active: true, | |
| })); | |
| for (const entry of entries) { | |
| await db | |
| .insert(branchConfig) | |
| .values(entry) | |
| .onConflictDoNothing(); | |
| } | |
| console.log(`Seeded ${entries.length} branch mappings.`); | |
| sqlite.close(); | |
| } | |
| seed().catch(console.error); | |