1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import prisma from '../../../src/prisma/PrismaClient';
- import { now } from '../../../src/utils/TimeLocal';
- const cityNames: string[] = [
- 'Kabupaten Deiyai',
- 'Kabupaten Dogiyai',
- 'Kabupaten Intan Jaya',
- 'Kabupaten Mimika',
- 'Kabupaten Nabire',
- 'Kabupaten Paniai',
- 'Kabupaten Puncak',
- 'Kabupaten Puncak Jaya',
- ];
- export const seedPapuaTengahCities = async (): Promise<void> => {
- const province = await prisma.province.findFirst({
- where: { name: 'Papua Tengah' },
- });
- if (!province) {
- console.error('❌ Province Papua 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: now().toDate(),
- },
- create: {
- name,
- province_id: province.id,
- createdAt: now().toDate(),
- },
- });
- }
- console.log('✅ Papua Tengah City seeded!.');
- };
- // const prisma = require('../../../src/prisma/PrismaClient.js');
- // const timeLocal = require('../../../src/utils/TimeLocal.js')
- // const cityNames = [
- // 'Kabupaten Deiyai',
- // 'Kabupaten Dogiyai',
- // 'Kabupaten Intan Jaya',
- // 'Kabupaten Mimika',
- // 'Kabupaten Nabire',
- // 'Kabupaten Paniai',
- // 'Kabupaten Puncak',
- // 'Kabupaten Puncak Jaya'
- // // 8
- // ];
- // exports.seedPapuaTengahCities = async () => {
- // const province = await prisma.province.findFirst({
- // where: { name: 'Papua Tengah' },
- // });
- // if (!province) {
- // console.error('❌ Province Papua 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('✅ Papua Tengah City seeded!.');
- // };
|