import prisma from '../../../src/prisma/PrismaClient'; import { now } from '../../../src/utils/TimeLocal'; const cityNames: string[] = [ 'Kabupaten Lebak', 'Kabupaten Pandeglang', 'Kabupaten Serang', 'Kabupaten Tangerang', 'Kota Cilegon', 'Kota Serang', 'Kota Tangerang', 'Kota Tangerang Selatan' ]; export async function seedBantenCities(): Promise { const province = await prisma.province.findFirst({ where: { name: 'Banten' }, }); if (!province) { console.error('❌ Province Banten not found. Seed it first.'); return; } for (const name of cityNames) { await prisma.city.upsert({ where: { name_province_id: { name, province_id: province.id, }, }, update: { updatedAt: now().toDate(), }, create: { name, province_id: province.id, createdAt: now().toDate(), }, }); } console.log('✅ Banten City seeded!'); } // const prisma = require('../../../src/prisma/PrismaClient.js'); // const timeLocal = require('../../../src/utils/TimeLocal.js') // const cityNames = [ // 'Kabupaten Lebak', // 'Kabupaten Pandeglang', // 'Kabupaten Serang', // 'Kabupaten Tangerang', // 'Kota Cilegon', // 'Kota Serang', // 'Kota Tangerang', // 'Kota Tangerang Selatan' // // 8 // ]; // exports.seedBantenCities = async () => { // const province = await prisma.province.findFirst({ // where: { name: 'Banten' }, // }); // if (!province) { // console.error('❌ Province Banten not found. Seed it first.'); // return; // } // for (const name of cityNames) { // await prisma.city.upsert({ // where: { // name_province_id: { // name, // province_id: province.id, // }, // }, // update: { // updatedAt: timeLocal.now().toDate() // }, // create: { // name, // province_id: province.id, // createdAt: timeLocal.now().toDate() // }, // }); // } // console.log('✅ Banten City seeded!.'); // };