1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import prisma from '../../../src/prisma/PrismaClient';
- import { now } from '../../../src/utils/TimeLocal';
- const cityNames: string[] = [
- 'Kabupaten Bantul',
- 'Kabupaten Gunungkidul',
- 'Kabupaten Kulon Progo',
- 'Kabupaten Sleman',
- 'Kota Yogyakarta'
- ];
- export async function seedDIYogyakartaCities(): Promise<void> {
- const province = await prisma.province.findFirst({
- where: { name: 'DI Yogyakarta' },
- });
- if (!province) {
- console.error('❌ Province DI Yogyakarta 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('✅ DI Yogyakarta City seeded!');
- }
- // const prisma = require('../../../src/prisma/PrismaClient.js');
- // const timeLocal = require('../../../src/utils/TimeLocal.js')
- // const cityNames = [
- // 'Kabupaten Bantul',
- // 'Kabupaten Gunungkidul',
- // 'Kabupaten Kulon Progo',
- // 'Kabupaten Sleman',
- // 'Kota Yogyakarta'
- // // 5
- // ];
- // exports.seedDIYogyakartaCities = async () => {
- // const province = await prisma.province.findFirst({
- // where: { name: 'DI Yogyakarta' },
- // });
- // if (!province) {
- // console.error('❌ Province DI Yogyakarta 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('✅ DI Yogyakarta City seeded!.');
- // };
|