first commit
This commit is contained in:
25
db/seed.ts
Normal file
25
db/seed.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { db } from "./index";
|
||||
import { users } from "./schema";
|
||||
import bcrypt from "bcryptjs";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
dotenv.config({ path: ".env.local" });
|
||||
|
||||
async function seed() {
|
||||
const hashedPassword = await bcrypt.hash("admin123", 10);
|
||||
|
||||
await db.insert(users).values({
|
||||
name: "Admin",
|
||||
email: "admin@admin.com",
|
||||
password: hashedPassword,
|
||||
role: "admin",
|
||||
}).onConflictDoNothing();
|
||||
|
||||
console.log("Admin user created.");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
seed().catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user