1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- const prisma = require('../../../src/prisma/PrismaClient.js');
- const timeLocal = require('../../../src/utils/TimeLocal.js')
- const cityNames = [
- 'Kabupaten Banggai',
- 'Kabupaten Banggai Kepulauan',
- 'Kabupaten Banggai Laut',
- 'Kabupaten Buol',
- 'Kabupaten Donggala',
- 'Kabupaten Morowali',
- 'Kabupaten Morowali Utara',
- 'Kabupaten Parigi Moutong',
- 'Kabupaten Poso',
- 'Kabupaten Sigi',
- 'Kabupaten Tojo Una-Una',
- 'Kabupaten Tolitoli',
- 'Kota Palu'
- // 13
- ];
- exports.seedSulawesiTengahCities = async () => {
- const province = await prisma.province.findFirst({
- where: { name: 'Sulawesi Tengah' },
- });
- if (!province) {
- console.error('❌ Province Sulawesi Tengah 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('✅ Sulawesi Tengah City seeded!.');
- };
|