123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- const prisma = require('../../../src/prisma/PrismaClient.js');
- const timeLocal = require('../../../src/utils/TimeLocal.js')
- const cityNames = [
- 'Kabupaten Boalemo',
- 'Kabupaten Bone Bolango',
- 'Kabupaten Gorontalo',
- 'Kabupaten Gorontalo Utara',
- 'Kabupaten Pohuwato',
- 'Kota Gorontalo'
- // 6
- ];
- exports.seedGorontaloCities = async () => {
- const province = await prisma.province.findFirst({
- where: { name: 'Gorontalo' },
- });
- if (!province) {
- console.error('❌ Province Gorontalo 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('✅ Gorontalo City seeded!.');
- };
|