Test foto gdrive
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import profilePejabatDesa from "./data/landing-page/profile/profile.json";
|
||||
import penghargaan from "./data/landing-page/penghargaan/penghargaan.json";
|
||||
import programInovasi from "./data/landing-page/profile/programInovasi.json";
|
||||
@@ -50,6 +52,32 @@ import pegawaiPPID from "./data/ppid/struktur-ppid/pegawai-PPID.json";
|
||||
import pelayananTelunjukSaktiDesa from "./data/desa/layanan/pelayananTelunjukSaktiDesa.json";
|
||||
|
||||
(async () => {
|
||||
//seed file storage
|
||||
const filePath = path.join(__dirname, "data/file-storage.json");
|
||||
const rawData = await fs.readFile(filePath, "utf-8");
|
||||
const files = JSON.parse(rawData);
|
||||
|
||||
console.log(`Seeding ${files.length} file(s) into FileStorage...`);
|
||||
|
||||
for (const file of files) {
|
||||
await prisma.fileStorage.upsert({
|
||||
where: { name: file.name },
|
||||
update: {},
|
||||
create: {
|
||||
id: file.id,
|
||||
name: file.name,
|
||||
realName: file.realName,
|
||||
path: file.path,
|
||||
link: file.link,
|
||||
category: file.category,
|
||||
mimeType: file.mimeType,
|
||||
isActive: file.isActive ?? true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log("✅ Seeding selesai!");
|
||||
|
||||
// =========== LANDING PAGE ===========
|
||||
// =========== PROFILE ===========
|
||||
for (const p of profilePejabatDesa) {
|
||||
@@ -127,16 +155,26 @@ import pelayananTelunjukSaktiDesa from "./data/desa/layanan/pelayananTelunjukSak
|
||||
|
||||
// =========== LAYANAN DESA ===========
|
||||
for (const p of pelayananSuratKeterangan) {
|
||||
// Skip if required image references don't exist
|
||||
if (!p.imageId || !p.image2Id) {
|
||||
console.warn(`Skipping ${p.name} due to missing image references`);
|
||||
continue;
|
||||
}
|
||||
|
||||
await prisma.pelayananSuratKeterangan.upsert({
|
||||
where: { id: p.id },
|
||||
update: {
|
||||
name: p.name,
|
||||
deskripsi: p.deskripsi,
|
||||
imageId: p.imageId,
|
||||
image2Id: p.image2Id,
|
||||
},
|
||||
create: {
|
||||
id: p.id,
|
||||
name: p.name,
|
||||
deskripsi: p.deskripsi,
|
||||
imageId: p.imageId,
|
||||
image2Id: p.image2Id,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -495,7 +533,7 @@ import pelayananTelunjukSaktiDesa from "./data/desa/layanan/pelayananTelunjukSak
|
||||
riwayat: c.riwayat,
|
||||
pengalaman: c.pengalaman,
|
||||
unggulan: c.unggulan,
|
||||
// imageId tidak di-update
|
||||
imageId: c.imageId,
|
||||
},
|
||||
create: {
|
||||
id: c.id,
|
||||
@@ -504,7 +542,7 @@ import pelayananTelunjukSaktiDesa from "./data/desa/layanan/pelayananTelunjukSak
|
||||
riwayat: c.riwayat,
|
||||
pengalaman: c.pengalaman,
|
||||
unggulan: c.unggulan,
|
||||
// imageId tidak di-create
|
||||
imageId: c.imageId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user