Deskripsi: - update database - update seeder categori pelayanan surat No Issues
105 lines
2.0 KiB
TypeScript
105 lines
2.0 KiB
TypeScript
import { categoryPelayananSurat } from "@/lib/categoryPelayananSurat";
|
|
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`)
|
|
}
|
|
|
|
for (const cp of categoryPelayananSurat){
|
|
await prisma.categoryPelayanan.upsert({
|
|
where: { id: cp.id },
|
|
create: cp,
|
|
update: cp
|
|
})
|
|
|
|
console.log(`✅ Category Pelayanan ${cp.name} seeded successfully`)
|
|
}
|
|
|
|
|
|
|
|
|
|
})().catch((e) => {
|
|
console.error(e)
|
|
process.exit(1)
|
|
}).finally(() => {
|
|
console.log("✅ Seeding completed successfully ")
|
|
process.exit(0)
|
|
})
|
|
|