Files
jenna-mcp/prisma/seed.ts
amaliadwiy 06feeae9a5 upd: api pengaduan
Deskripsi:
- update seeder kategori pengaduan
- list pengaduan warga

NO Issues
2025-10-29 14:41:40 +08:00

94 lines
1.6 KiB
TypeScript

import { prisma } from "@/server/lib/prisma";
const category = [
{
id: "lainnya",
name: "Lainnya"
},
{
id: "kebersihan",
name: "Kebersihan"
},
{
id: "keamanan",
name: "Keamanan"
},
{
id: "pelayanan",
name: "Pelayanan"
},
{
id: "infrastruktur",
name: "Infrastruktur"
},
]
const role = [
{
id: "developer",
name: "developer"
},
{
id: "admin",
name: "admin"
},
{
id: "pelaksana",
name: "pelaksana"
}
]
const user = [
{
id: "bip",
name: "Bip",
email: "bip@bip.com",
password: "bip",
roleId: "developer"
}
];
(async () => {
for (const r of role) {
console.log(`Seeding role ${r.name}`)
await prisma.role.upsert({
where: { id: r.id },
create: r,
update: r
})
console.log(`✅ Role ${r.name} seeded successfully`)
}
for (const u of user) {
await prisma.user.upsert({
where: { email: u.email },
create: u,
update: u
})
console.log(`✅ User ${u.email} seeded successfully`)
}
for (const c of category) {
await prisma.categoryPengaduan.upsert({
where: { id: c.id },
create: c,
update: c
})
console.log(`✅ Category ${c.name} seeded successfully`)
}
})().catch((e) => {
console.error(e)
process.exit(1)
}).finally(() => {
console.log("✅ Seeding completed successfully ")
process.exit(0)
})