import prisma from '../../../src/prisma/PrismaClient'; import { now } from '../../../src/utils/TimeLocal'; const cityNames: string[] = [ 'Kabupaten Halmahera Barat', 'Kabupaten Halmahera Tengah', 'Kabupaten Halmahera Timur', 'Kabupaten Halmahera Selatan', 'Kabupaten Halmahera Utara', 'Kabupaten Kepulauan Sula', 'Kabupaten Pulau Morotai', 'Kabupaten Pulau Taliabu', 'Kota Ternate', 'Kota Tidore Kepulauan' ]; export async function seedMalukuUtaraCities(): Promise { const province = await prisma.province.findFirst({ where: { name: 'Maluku Utara' }, }); if (!province) { console.error('❌ Province Maluku Utara 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('✅ Maluku Utara City seeded!'); } // const prisma = require('../../../src/prisma/PrismaClient.js'); // const timeLocal = require('../../../src/utils/TimeLocal.js') // const cityNames = [ // 'Kabupaten Halmahera Barat', // 'Kabupaten Halmahera Tengah', // 'Kabupaten Halmahera Timur', // 'Kabupaten Halmahera Selatan', // 'Kabupaten Halmahera Utara', // 'Kabupaten Kepulauan Sula', // 'Kabupaten Pulau Morotai', // 'Kabupaten Pulau Taliabu', // 'Kota Ternate', // 'Kota Tidore Kepulauan' // // 10 // ]; // exports.seedMalukuUtaraCities = async () => { // const province = await prisma.province.findFirst({ // where: { name: 'Maluku Utara' }, // }); // if (!province) { // console.error('❌ Province Maluku Utara 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('✅ Maluku Utara City seeded!.'); // };