Newer
Older
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
37
38
39
40
41
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
// eslint-disable-next-line no-console
const log = (...msg: any[]) => console.log(...msg);
async function main() {
const SETTINGS: { key: string; defaultValue: any }[] = [
{
key: "canvas.size",
defaultValue: {
width: 100,
height: 100,
},
},
];
for (const setting of SETTINGS) {
log("Ensuring setting", setting.key);
await prisma.setting.upsert({
where: { key: setting.key },
update: {},
create: {
key: setting.key,
value: JSON.stringify(setting.defaultValue),
},
});
}
}
main()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (e) => {
// eslint-disable-next-line no-console
console.error(e);
await prisma.$disconnect();
process.exit(1);
});