|
|
|
@ -1,25 +1,23 @@ |
|
|
|
import './env'; |
|
|
|
import { seed } from "drizzle-seed"; |
|
|
|
import { usersTable } from "./lib/schema/schema"; |
|
|
|
import { dbGlobal } from "./lib/db"; |
|
|
|
import { usersTable } from "./lib/schema/schema"; |
|
|
|
import bcrypt from "bcryptjs"; |
|
|
|
|
|
|
|
async function main() { |
|
|
|
await seed(dbGlobal, { usersTable }).refine((f) => ({ |
|
|
|
usersTable: { |
|
|
|
columns: { |
|
|
|
name: f.fullName(), |
|
|
|
age: f.int({ minValue: 18, maxValue: 60 }), |
|
|
|
email: f.email(), |
|
|
|
}, |
|
|
|
count: 10, |
|
|
|
}, |
|
|
|
})); |
|
|
|
console.log('Seed complete!'); |
|
|
|
process.exit(0); |
|
|
|
const passwordHash = bcrypt.hashSync("seed-password-123", 10); |
|
|
|
await dbGlobal.insert(usersTable).values( |
|
|
|
Array.from({ length: 5 }).map((_, i) => ({ |
|
|
|
name: `Seed User ${i}`, |
|
|
|
age: 20 + i, |
|
|
|
email: `seed${i}@example.com`, |
|
|
|
passwordHash, |
|
|
|
})), |
|
|
|
); |
|
|
|
console.log('Seed complete!'); |
|
|
|
process.exit(0); |
|
|
|
} |
|
|
|
|
|
|
|
main().catch(e => { |
|
|
|
console.error(e); |
|
|
|
process.exit(1); |
|
|
|
main().catch((e) => { |
|
|
|
console.error(e); |
|
|
|
process.exit(1); |
|
|
|
}); |
|
|
|
|
|
|
|
|