mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-02-22 18:01:59 +00:00
add seed script and use postgres for db
This commit is contained in:
parent
e9c71c1e58
commit
a0d85b1f12
@ -9,8 +9,8 @@ generator client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
provider = "sqlite"
|
provider = "postgresql"
|
||||||
url = "file:./dev.db"
|
url = env("DATABASE_URL")
|
||||||
}
|
}
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
|
36
prisma/seed.ts
Normal file
36
prisma/seed.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { faker } from "@faker-js/faker";
|
||||||
|
import { PrismaClient } from "@prisma/client";
|
||||||
|
|
||||||
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const users = Array.from({ length: 25 }, () => ({
|
||||||
|
name: `${faker.person.fullName().split(" ")[1]} House-${crypto
|
||||||
|
.randomUUID()
|
||||||
|
.slice(0, 5)}`,
|
||||||
|
email: faker.internet.email(),
|
||||||
|
emailVerified: false,
|
||||||
|
firstPaymentDone: false,
|
||||||
|
verified: false,
|
||||||
|
house_name: faker.location.streetAddress(),
|
||||||
|
id_card: `A${Math.round(Math.random() * 999999)}`,
|
||||||
|
dob: faker.date.between({
|
||||||
|
from: "1900-01-01",
|
||||||
|
to: "2000-01-01",
|
||||||
|
}),
|
||||||
|
phoneNumber: String(faker.number.int({ min: 7000000, max: 9999999 })),
|
||||||
|
phoneNumberVerified: false,
|
||||||
|
role: "USER",
|
||||||
|
}));
|
||||||
|
await prisma.user.createMany({
|
||||||
|
data: users,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
.then(() => prisma.$disconnect())
|
||||||
|
.catch(async (e) => {
|
||||||
|
console.error(e);
|
||||||
|
await prisma.$disconnect();
|
||||||
|
process.exit(1);
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user