blob: a5d7752cd5e0865644b782e51fbc526695d2423f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import { prisma } from ".";
import type { User } from "@prisma/client";
const DEFAULT_USERS = [
// Add your own user to pre-populate the database with
{
name: "Tim Apple",
email: "tim@apple.com",
},
] as Array<Partial<User>>;
(async () => {
try {
await Promise.all(
DEFAULT_USERS.map((user) =>
prisma.user.upsert({
where: {
email: user.email!,
},
update: {
...user,
},
create: {
...user,
},
})
)
);
} catch (error) {
console.error(error);
process.exit(1);
} finally {
await prisma.$disconnect();
}
})();
|