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,41 @@
import prisma from "@/lib/prisma";
import sdgsDesa from "../../../data/landing-page/sdgs-desa/sdgs-desa.json";
export async function seedSDGSDesa() {
console.log("🔄 Seeding SDGS Desa...");
for (const m of sdgsDesa) {
let imageId: string | null = null;
if (m.imageName) {
const image = await prisma.fileStorage.findUnique({
where: { name: m.imageName },
select: { id: true },
});
if (!image) {
console.warn(
`⚠️ Image not found for sdgs desa "${m.name}": ${m.imageName}`,
);
} else {
imageId = image.id;
}
}
await prisma.sdgsDesa.upsert({
where: { id: m.id },
update: {
name: m.name,
jumlah: m.jumlah,
imageId,
},
create: {
id: m.id,
name: m.name,
jumlah: m.jumlah,
imageId,
},
});
}
console.log("sdgs desa success ...");
}