import { drizzle } from 'drizzle-orm/node-postgres'; import { Pool } from 'pg'; import { users } from '../src/db/schema.ts'; const pool = new Pool({ connectionString: process.env.DATABASE_URL! }); const db = drizzle(pool); const BATCH = 100; const TOTAL = 1000; const password = await Bun.password.hash('password'); console.log(`Inserting ${TOTAL} users...`); for (let i = 0; i < TOTAL; i += BATCH) { const batch = []; for (let j = i; j < Math.min(i + BATCH, TOTAL); j++) { const n = String(j).padStart(4, '0'); batch.push({ username: `user${n}`, email: `user${n}@test.local`, role: 'staff', password_hash: password, }); } await db.insert(users).values(batch as any).onConflictDoNothing(); process.stdout.write('.'); } console.log(`\nDone. ${TOTAL} users seeded.`); await pool.end();