12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- import prisma from '../../../src/prisma/PrismaClient';
- import { now } from '../../../src/utils/TimeLocal';
- const cityNames: string[] = [
- 'Kabupaten Majene',
- 'Kabupaten Mamasa',
- 'Kabupaten Mamuju',
- 'Kabupaten Mamuju Tengah',
- 'Kabupaten Pasangkayu',
- 'Kabupaten Polewali Mandar'
- ];
- export const seedSulawesiBaratCities = async (): Promise<void> => {
- const province = await prisma.province.findFirst({
- where: { name: 'Sulawesi Barat' },
- });
- if (!province) {
- console.error('❌ Province Sulawesi Barat not found. Seed it first.');
- return;
- }
- for (const name of cityNames) {
- await prisma.city.upsert({
- where: {
- // Pastikan ada @@unique([name, province_id]) di model City di schema.prisma
- name_province_id: {
- name,
- province_id: province.id,
- },
- },
- update: {
- updatedAt: now().toDate(),
- },
- create: {
- name,
- province_id: province.id,
- createdAt: now().toDate(),
- },
- });
- }
- console.log('✅ Sulawesi Barat City seeded!.');
- };
- // const prisma = require('../../../src/prisma/PrismaClient.js');
- // const timeLocal = require('../../../src/utils/TimeLocal.js')
- // const cityNames = [
- // 'Kabupaten Majene',
- // 'Kabupaten Mamasa',
- // 'Kabupaten Mamuju',
- // 'Kabupaten Mamuju Tengah',
- // 'Kabupaten Pasangkayu',
- // 'Kabupaten Polewali Mandar'
- // // 6
- // ];
- // exports.seedSulawesiBaratCities = async () => {
- // const province = await prisma.province.findFirst({
- // where: { name: 'Sulawesi Barat' },
- // });
- // if (!province) {
- // console.error('❌ Province Sulawesi Barat 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 Barat City seeded!.');
- // };
|