Fix Seeder Image, Menu Landing Page - Desa

This commit is contained in:
2026-01-30 15:55:05 +08:00
parent c2ad515366
commit f0425cfc47
61 changed files with 4533 additions and 5162 deletions

View File

@@ -0,0 +1,43 @@
import prisma from "@/lib/prisma";
import { safeSeedUnique } from "../../../safeseedUnique";
import kategoriPengumuman from "../../../data/desa/pengumuman/kategori-pengumuman.json";
import pengumuman from "../../../data/desa/pengumuman/pengumuman.json";
export async function seedPengumuman() {
console.log("🔄 Seeding Kategori Pengumuman...");
for (const c of kategoriPengumuman) {
await safeSeedUnique(
"categoryPengumuman",
{ name: c.name }, // ✅ where clause
{
id: c.id,
name: c.name,
},
);
}
console.log("kategori pengumuman success ...");
console.log("🔄 Seeding Pengumuman...");
for (const p of pengumuman) {
await prisma.pengumuman.upsert({
where: {
id: p.id,
},
update: {
judul: p.judul,
deskripsi: p.deskripsi,
content: p.content,
categoryPengumumanId: p.categoryPengumumanId,
},
create: {
judul: p.judul,
deskripsi: p.deskripsi,
content: p.content,
categoryPengumumanId: p.categoryPengumumanId,
},
});
}
console.log("pengumuman success ...");
}