KalimantanTengahCitySeeder.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. const prisma = require('../../../src/prisma/PrismaClient.js');
  2. const timeLocal = require('../../../src/utils/TimeLocal.js')
  3. const cityNames = [
  4. 'Kabupaten Barito Selatan',
  5. 'Kabupaten Barito Timur',
  6. 'Kabupaten Barito Utara',
  7. 'Kabupaten Gunung Mas',
  8. 'Kabupaten Kapuas',
  9. 'Kabupaten Katingan',
  10. 'Kabupaten Kotawaringin Barat',
  11. 'Kabupaten Kotawaringin Timur',
  12. 'Kabupaten Lamandau',
  13. 'Kabupaten Murung Raya',
  14. 'Kabupaten Pulang Pisau',
  15. 'Kabupaten Sukamara',
  16. 'Kabupaten Seruyan',
  17. 'Kota Palangka Raya'
  18. // 14
  19. ];
  20. exports.seedKalimantanTengahCities = async () => {
  21. const province = await prisma.province.findFirst({
  22. where: { name: 'Kalimantan Tengah' },
  23. });
  24. if (!province) {
  25. console.error('❌ Province Kalimantan Tengah not found. Seed it first.');
  26. return;
  27. }
  28. for (const name of cityNames) {
  29. await prisma.city.upsert({
  30. where: {
  31. name_province_id: {
  32. name,
  33. province_id: province.id,
  34. },
  35. },
  36. update: {
  37. updatedAt: timeLocal.now().toDate()
  38. },
  39. create: {
  40. name,
  41. province_id: province.id,
  42. createdAt: timeLocal.now().toDate()
  43. },
  44. });
  45. }
  46. console.log('✅ Kalimantan Tengah City seeded!.');
  47. };