Browse Source

Merge branch 'development'

pearlgw 1 month ago
parent
commit
2050316eb8
100 changed files with 5646 additions and 2601 deletions
  1. 36 8
      .env.example
  2. 0 6
      config/config.js
  3. 15 0
      config/config.ts
  4. 0 10
      config/keycloak.js
  5. 21 0
      config/keycloak.ts
  6. 2 1
      entrypoint.sh
  7. 0 53
      index.js
  8. 46 0
      index.ts
  9. 788 8
      package-lock.json
  10. 21 5
      package.json
  11. 2 0
      prisma/migrations/20250729072052_solve/migration.sql
  12. 1 1
      prisma/schema.prisma
  13. 0 97
      prisma/seeders/DatabaseSeeder.js
  14. 101 0
      prisma/seeders/DatabaseSeeder.ts
  15. 0 146
      prisma/seeders/HospitalSeeder.js
  16. 261 0
      prisma/seeders/HospitalSeeder.ts
  17. 0 30
      prisma/seeders/ProvinceSeeder.js
  18. 41 0
      prisma/seeders/ProvinceSeeder.ts
  19. 0 53
      prisma/seeders/UserAreaSeeder.js
  20. 84 0
      prisma/seeders/UserAreaSeeder.ts
  21. 0 148
      prisma/seeders/UserSeeder.js
  22. 306 0
      prisma/seeders/UserSeeder.ts
  23. 0 69
      prisma/seeders/VendorSeeder.js
  24. 123 0
      prisma/seeders/VendorSeeder.ts
  25. 0 62
      prisma/seeders/city/AcehCitySeeder.js
  26. 124 0
      prisma/seeders/city/AcehCitySeeder.ts
  27. 0 48
      prisma/seeders/city/BaliCitySeeder.js
  28. 96 0
      prisma/seeders/city/BaliCitySeeder.ts
  29. 0 47
      prisma/seeders/city/BantenCitySeeder.js
  30. 93 0
      prisma/seeders/city/BantenCitySeeder.ts
  31. 0 47
      prisma/seeders/city/BengkuluCitySeeder.js
  32. 96 0
      prisma/seeders/city/BengkuluCitySeeder.ts
  33. 0 42
      prisma/seeders/city/DIYogyakartaCitySeeder.js
  34. 83 0
      prisma/seeders/city/DIYogyakartaCitySeeder.ts
  35. 0 45
      prisma/seeders/city/DKIJakartaCitySeeder.js
  36. 90 0
      prisma/seeders/city/DKIJakartaCitySeeder.ts
  37. 0 45
      prisma/seeders/city/GorontaloCitySeeder.js
  38. 89 0
      prisma/seeders/city/GorontaloCitySeeder.ts
  39. 0 50
      prisma/seeders/city/JambiCitySeeder.js
  40. 100 0
      prisma/seeders/city/JambiCitySeeder.ts
  41. 0 66
      prisma/seeders/city/JawaBaratCitySeeder.js
  42. 131 0
      prisma/seeders/city/JawaBaratCitySeeder.ts
  43. 0 74
      prisma/seeders/city/JawaTengahCitySeeder.js
  44. 147 0
      prisma/seeders/city/JawaTengahCitySeeder.ts
  45. 0 77
      prisma/seeders/city/JawaTimurCitySeeder.js
  46. 153 0
      prisma/seeders/city/JawaTimurCitySeeder.ts
  47. 0 53
      prisma/seeders/city/KalimantanBaratCitySeeder.js
  48. 105 0
      prisma/seeders/city/KalimantanBaratCitySeeder.ts
  49. 0 52
      prisma/seeders/city/KalimantanSelatanCitySeeder.js
  50. 103 0
      prisma/seeders/city/KalimantanSelatanCitySeeder.ts
  51. 0 53
      prisma/seeders/city/KalimantanTengahCitySeeder.js
  52. 105 0
      prisma/seeders/city/KalimantanTengahCitySeeder.ts
  53. 0 49
      prisma/seeders/city/KalimantanTimurCitySeeder.js
  54. 98 0
      prisma/seeders/city/KalimantanTimurCitySeeder.ts
  55. 0 44
      prisma/seeders/city/KalimantanUtaraCitySeeder.js
  56. 87 0
      prisma/seeders/city/KalimantanUtaraCitySeeder.ts
  57. 0 46
      prisma/seeders/city/KepulauanBangkaBelitungCitySeeder.js
  58. 91 0
      prisma/seeders/city/KepulauanBangkaBelitungCitySeeder.ts
  59. 0 46
      prisma/seeders/city/KepulauanRiauCitySeeder.js
  60. 91 0
      prisma/seeders/city/KepulauanRiauCitySeeder.ts
  61. 0 54
      prisma/seeders/city/LampungCitySeeder.js
  62. 107 0
      prisma/seeders/city/LampungCitySeeder.ts
  63. 0 50
      prisma/seeders/city/MalukuCitySeeder.js
  64. 99 0
      prisma/seeders/city/MalukuCitySeeder.ts
  65. 0 49
      prisma/seeders/city/MalukuUtaraCitySeeder.js
  66. 97 0
      prisma/seeders/city/MalukuUtaraCitySeeder.ts
  67. 0 49
      prisma/seeders/city/NusaTenggaraBaratCitySeeder.js
  68. 97 0
      prisma/seeders/city/NusaTenggaraBaratCitySeeder.ts
  69. 0 61
      prisma/seeders/city/NusaTenggaraTimurCitySeeder.js
  70. 121 0
      prisma/seeders/city/NusaTenggaraTimurCitySeeder.ts
  71. 0 46
      prisma/seeders/city/PapuaBaratCitySeeder.js
  72. 92 0
      prisma/seeders/city/PapuaBaratCitySeeder.ts
  73. 0 45
      prisma/seeders/city/PapuaBaratDayaCitySeeder.js
  74. 90 0
      prisma/seeders/city/PapuaBaratDayaCitySeeder.ts
  75. 0 46
      prisma/seeders/city/PapuaCitySeeder.js
  76. 93 0
      prisma/seeders/city/PapuaCitySeeder.ts
  77. 0 45
      prisma/seeders/city/PapuaPegununganCitySeeder.js
  78. 92 0
      prisma/seeders/city/PapuaPegununganCitySeeder.ts
  79. 0 41
      prisma/seeders/city/PapuaSelatanCitySeeder.js
  80. 84 0
      prisma/seeders/city/PapuaSelatanCitySeeder.ts
  81. 0 45
      prisma/seeders/city/PapuaTengahCitySeeder.js
  82. 92 0
      prisma/seeders/city/PapuaTengahCitySeeder.ts
  83. 0 49
      prisma/seeders/city/RiauCitySeeder.js
  84. 100 0
      prisma/seeders/city/RiauCitySeeder.ts
  85. 0 43
      prisma/seeders/city/SulawesiBaratCitySeeder.js
  86. 88 0
      prisma/seeders/city/SulawesiBaratCitySeeder.ts
  87. 0 61
      prisma/seeders/city/SulawesiSelatanCitySeeder.js
  88. 124 0
      prisma/seeders/city/SulawesiSelatanCitySeeder.ts
  89. 0 50
      prisma/seeders/city/SulawesiTengahCitySeeder.js
  90. 102 0
      prisma/seeders/city/SulawesiTengahCitySeeder.ts
  91. 0 54
      prisma/seeders/city/SulawesiTenggaraCitySeeder.js
  92. 110 0
      prisma/seeders/city/SulawesiTenggaraCitySeeder.ts
  93. 0 52
      prisma/seeders/city/SulawesiUtaraCitySeeder.js
  94. 105 0
      prisma/seeders/city/SulawesiUtaraCitySeeder.ts
  95. 0 56
      prisma/seeders/city/SumateraBaratCitySeeder.js
  96. 113 0
      prisma/seeders/city/SumateraBaratCitySeeder.ts
  97. 0 54
      prisma/seeders/city/SumateraSelatanCitySeeder.js
  98. 110 0
      prisma/seeders/city/SumateraSelatanCitySeeder.ts
  99. 0 70
      prisma/seeders/city/SumateraUtaraCitySeeder.js
  100. 0 0
      prisma/seeders/city/SumateraUtaraCitySeeder.ts

+ 36 - 8
.env.example

@@ -9,14 +9,42 @@
9 9
 # one found in a remote Prisma Postgres URL, does not contain any sensitive information.
10 10
 
11 11
 # Database
12
-DATABASE_URL="postgresql://postgres:postgres@localhost:5432/<namadb>"
12
+DATABASE_URL="postgresql://postgres:postgres@localhost:<port>/<name>"
13
+# DATABASE_URL="postgresql://postgres123:postgres123@db:5432/db_radar"
14
+# DATABASE_URL=postgresql://postgres123:postgres123@db:5432/db_radar
13 15
 
14 16
 PORT=3200
15 17
 
16
-# Keycloak
17
-KEYCLOAK_TOKEN_URL=<url>/realms/<name_realm>/protocol/openid-connect/token
18
-CLIENT_ID=my-app
19
-CLIENT_SECRET=vUT3dbn2EfYslBYMm0cjvvA6D5bLT2mH
20
-JWT_SECRET=FF9q223buywGKYfLbu4ojSOYJ9s63G0iJFiCwSiVXB4FOm4WJQMoOF7DubqYT46v
21
-KEYCLOAK_ADMIN_URL=<url>
22
-KEYCLOAK_REALM=<name_realm>
18
+# Keycloak lokal
19
+KEYCLOAK_TOKEN_URL=http://localhost:8020/realms/<name_realm>/protocol/openid-connect/token
20
+CLIENT_ID=<name_client>
21
+CLIENT_SECRET=<client_secret>
22
+KEYCLOAK_ADMIN_URL=http://localhost:<port_keycloak>
23
+# KEYCLOAK_REALM=pearlgw
24
+
25
+KEYCLOAK_REALM=pearlgw
26
+KEYCLOAK_CLIENT=<name_client>
27
+KEYCLOAK_URL=http://localhost:<port_keycloak>
28
+
29
+KEYCLOAK_ADMIN_CLIENT=admin-cli
30
+KEYCLOAK_ADMIN_USERNAME=<username>
31
+KEYCLOAK_ADMIN_PASSWORD=<password>
32
+
33
+# jwt
34
+JWT_SECRET=<jwt_secret>
35
+
36
+# Keycloak production
37
+# KEYCLOAK_TOKEN_URL=https://keycloak.natagw.my.id/realms/radar/protocol/openid-connect/token
38
+# CLIENT_ID=fg-radar
39
+# CLIENT_SECRET=7kVIBw6FYdHhjLRfnruLj4l8X0qlP2Yz
40
+# KEYCLOAK_ADMIN_URL=https://keycloak.natagw.my.id
41
+# KEYCLOAK_REALM=radar
42
+
43
+# Keycloak production server fg
44
+# KEYCLOAK_TOKEN_URL=https://keycloak-radar.natagw.my.id/realms/radar/protocol/openid-connect/token
45
+# CLIENT_ID=fg-radar
46
+# CLIENT_SECRET=t6qZPIqOuukAsZWDLyi9CMHFE9mva4cs
47
+# KEYCLOAK_ADMIN_URL=https://keycloak-radar.natagw.my.id
48
+# KEYCLOAK_REALM=radar
49
+
50
+BASE_URL=http://localhost:3200

+ 0 - 6
config/config.js

@@ -1,6 +0,0 @@
1
-require('dotenv').config();
2
-
3
-module.exports = {
4
-  port: process.env.PORT || 3000,
5
-  BASE_URL: process.env.BASE_URL || 'http://localhost:3200'
6
-};

+ 15 - 0
config/config.ts

@@ -0,0 +1,15 @@
1
+import dotenv from 'dotenv';
2
+
3
+dotenv.config();
4
+
5
+export const config = {
6
+  port: process.env.PORT ? parseInt(process.env.PORT) : 3000,
7
+  BASE_URL: process.env.BASE_URL || 'http://localhost:3200',
8
+};
9
+
10
+// require('dotenv').config();
11
+
12
+// module.exports = {
13
+//   port: process.env.PORT || 3000,
14
+//   BASE_URL: process.env.BASE_URL || 'http://localhost:3200'
15
+// };

+ 0 - 10
config/keycloak.js

@@ -1,10 +0,0 @@
1
-require('dotenv').config();
2
-
3
-module.exports = {
4
-    KEYCLOAK_TOKEN_URL: process.env.KEYCLOAK_TOKEN_URL,
5
-    CLIENT_ID: process.env.CLIENT_ID,
6
-    CLIENT_SECRET: process.env.CLIENT_SECRET,
7
-    JWT_SECRET: process.env.JWT_SECRET,
8
-    KEYCLOAK_ADMIN_URL: process.env.KEYCLOAK_ADMIN_URL,
9
-    KEYCLOAK_REALM: process.env.KEYCLOAK_REALM,
10
-};

+ 21 - 0
config/keycloak.ts

@@ -0,0 +1,21 @@
1
+import dotenv from 'dotenv';
2
+
3
+dotenv.config();
4
+
5
+export const KEYCLOAK_TOKEN_URL = process.env.KEYCLOAK_TOKEN_URL as string;
6
+export const CLIENT_ID = process.env.CLIENT_ID as string;
7
+export const CLIENT_SECRET = process.env.CLIENT_SECRET as string;
8
+export const JWT_SECRET = process.env.JWT_SECRET as string;
9
+export const KEYCLOAK_ADMIN_URL = process.env.KEYCLOAK_ADMIN_URL as string;
10
+export const KEYCLOAK_REALM = process.env.KEYCLOAK_REALM as string;
11
+
12
+// require('dotenv').config();
13
+
14
+// module.exports = {
15
+//     KEYCLOAK_TOKEN_URL: process.env.KEYCLOAK_TOKEN_URL,
16
+//     CLIENT_ID: process.env.CLIENT_ID,
17
+//     CLIENT_SECRET: process.env.CLIENT_SECRET,
18
+//     JWT_SECRET: process.env.JWT_SECRET,
19
+//     KEYCLOAK_ADMIN_URL: process.env.KEYCLOAK_ADMIN_URL,
20
+//     KEYCLOAK_REALM: process.env.KEYCLOAK_REALM,
21
+// };

+ 2 - 1
entrypoint.sh

@@ -13,6 +13,7 @@ npx prisma migrate dev --name init
13 13
 # npx prisma db seed
14 14
 
15 15
 echo "🚀 Menjalankan aplikasi..."
16
-exec node index.js
16
+# exec node index.js
17
+exec nodemon
17 18
 
18 19
 # cara jalaninnya, kan databaseseeder dulu, setelah itu node prisma/seeders/UserAreaSeeder, HospitalSeeder, VendorSeeder

+ 0 - 53
index.js

@@ -1,53 +0,0 @@
1
-const express = require('express')
2
-const cors = require('cors')
3
-const errorHandler = require('./src/middleware/ErrorHandler.js')
4
-const app = express()
5
-const path = require('path');
6
-// const hospitalRoutes = require('./src/routes/HospitalRoute.js')
7
-const provinceRoutes = require('./src/routes/admin/ProvinceRoute.js')
8
-const authRoutes = require('./src/routes/auth/AuthRoute.js')
9
-// const userRoutes = require('./src/routes/UserRoute.js')
10
-const cityRoutes = require('./src/routes/admin/CityRoute.js')
11
-const salesRoutes = require('./src/routes/admin/SalesRoute.js')
12
-const adminRoutes = require('./src/routes/superadmin/AdminRoute.js')
13
-const hospitalRoutes = require('./src/routes/admin/HospitalRoute.js')
14
-const salesHospitalRoutes = require('./src/routes/sales/HospitalRoute.js')
15
-const vendorRoutes = require('./src/routes/admin/VendorRoute.js')
16
-const logRoutes = require('./src/routes/superadmin/LogRoute.js')
17
-const areaRoutes = require('./src/routes/sales/AreaRoute.js')
18
-const vendorSalesRoutes = require('./src/routes/sales/VendorRoute.js')
19
-const { port } = require('./config/config.js')
20
-const keycloak = require('./src/middleware/Keycloak.js');
21
-require("./src/utils/Scheduler.js")
22
-
23
-app.use(cors())
24
-app.use(keycloak.middleware());
25
-app.use(express.json())
26
-app.use('/storage/', express.static(path.join(__dirname, 'storage/')));
27
-
28
-const apiV1 = express.Router();
29
-
30
-// apiV1.use('/hospitals', hospitalRoutes);
31
-apiV1.use('/province', provinceRoutes);
32
-apiV1.use('/auth', authRoutes);
33
-// apiV1.use('/user', userRoutes);
34
-apiV1.use('/city', cityRoutes);
35
-apiV1.use('/sales', salesRoutes);
36
-apiV1.use('/admin', adminRoutes);
37
-apiV1.use('/hospital', hospitalRoutes);
38
-apiV1.use('/hospital-area', salesHospitalRoutes);
39
-apiV1.use('/vendor', vendorRoutes);
40
-apiV1.use('/logs', logRoutes);
41
-apiV1.use('/area', areaRoutes);
42
-apiV1.use('/vendor-sales', vendorSalesRoutes);
43
-
44
-app.get('/', (req, res) => {
45
-    res.send('Selamat Datang di API Radar Farmagitechs');
46
-});
47
-
48
-app.use('/v1/api', apiV1);
49
-app.use(errorHandler);
50
-
51
-app.listen(port, () => {
52
-    console.log(`Server started on port ${port}`);
53
-})

+ 46 - 0
index.ts

@@ -0,0 +1,46 @@
1
+import express, { Application, Request, Response } from 'express';
2
+import cors from 'cors';
3
+import path from 'path';
4
+import bodyParser from 'body-parser';
5
+
6
+import { errorHandler } from './src/middleware/ErrorHandler';
7
+import keycloak from './src/middleware/Keycloak';
8
+import { config } from './config/config';
9
+
10
+import provinceRoutes from './src/routes/admin/ProvinceRoute';
11
+import cityRoutes from './src/routes/admin/CityRoute';
12
+import vendorRoutes from './src/routes/admin/VendorRoute';
13
+import hospitalRoutes from './src/routes/admin/HospitalRoute';
14
+import salesHospitalRoutes from './src/routes/sales/HospitalRoute';
15
+import areaRoutes from './src/routes/sales/AreaRoute';
16
+
17
+import './src/utils/Scheduler';
18
+
19
+const app: Application = express();
20
+
21
+app.use(cors());
22
+app.use(bodyParser.json());
23
+app.use(keycloak.middleware());
24
+app.use(express.json())
25
+app.use('/storage/', express.static(path.join(__dirname, 'storage/')));
26
+
27
+const apiV1 = express.Router();
28
+
29
+apiV1.use('/province', provinceRoutes);
30
+apiV1.use('/city', cityRoutes);
31
+apiV1.use('/hospital', hospitalRoutes);
32
+apiV1.use('/hospital-area', salesHospitalRoutes);
33
+apiV1.use('/vendor', vendorRoutes);
34
+apiV1.use('/area', areaRoutes);
35
+// apiV1.use('/vendor-sales', vendorSalesRoutes);
36
+
37
+app.get('/', (req: Request, res: Response) => {
38
+    res.send('Selamat Datang di API Radar Farmagitechs');
39
+});
40
+
41
+app.use('/v1/api', apiV1);
42
+app.use(errorHandler);
43
+
44
+app.listen(config.port, () => {
45
+    console.log(`Server started on port ${config.port}`);
46
+})

File diff suppressed because it is too large
+ 788 - 8
package-lock.json


+ 21 - 5
package.json

@@ -1,12 +1,13 @@
1 1
 {
2 2
   "name": "proyek_radar_farmagitechs",
3 3
   "version": "1.0.0",
4
-  "main": "index.js",
4
+  "main": "index.ts",
5
+  "type": "commonjs",
5 6
   "scripts": {
6
-    "test": "echo \"Error: no test specified\" && exit 1"
7
+    "dev": "nodemon"
7 8
   },
8 9
   "prisma": {
9
-    "seed": "node prisma/seeders/DatabaseSeeder.js"
10
+    "seed": "ts-node prisma/seeders/DatabaseSeeder.ts"
10 11
   },
11 12
   "keywords": [],
12 13
   "author": "",
@@ -17,6 +18,7 @@
17 18
     "@prisma/client": "^6.10.1",
18 19
     "axios": "^1.10.0",
19 20
     "bcrypt": "^6.0.0",
21
+    "body-parser": "^2.2.0",
20 22
     "cors": "^2.8.5",
21 23
     "date-fns": "^4.1.0",
22 24
     "date-fns-tz": "^3.2.0",
@@ -24,14 +26,28 @@
24 26
     "dayjs-plugin-utc": "^0.1.2",
25 27
     "dotenv": "^16.5.0",
26 28
     "express": "^5.1.0",
29
+    "http-status-codes": "^2.3.0",
30
+    "joi": "^17.13.3",
27 31
     "jsonwebtoken": "^9.0.2",
28 32
     "keycloak-connect": "^26.1.1",
29 33
     "multer": "^2.0.1",
30 34
     "node-cron": "^4.2.1",
31 35
     "pg": "^8.16.2",
32
-    "qs": "^6.14.0"
36
+    "qs": "^6.14.0",
37
+    "zod": "^4.0.5"
33 38
   },
34 39
   "devDependencies": {
35
-    "prisma": "^6.10.1"
40
+    "@types/bcrypt": "^5.0.2",
41
+    "@types/cors": "^2.8.19",
42
+    "@types/express": "^5.0.3",
43
+    "@types/joi": "^17.2.2",
44
+    "@types/jsonwebtoken": "^9.0.10",
45
+    "@types/keycloak-connect": "^4.5.4",
46
+    "@types/multer": "^2.0.0",
47
+    "@types/node": "^24.0.14",
48
+    "nodemon": "^3.1.10",
49
+    "prisma": "^6.10.1",
50
+    "ts-node": "^10.9.2",
51
+    "typescript": "^5.8.3"
36 52
   }
37 53
 }

+ 2 - 0
prisma/migrations/20250729072052_solve/migration.sql

@@ -0,0 +1,2 @@
1
+-- DropIndex
2
+DROP INDEX "provinces_name_key";

+ 1 - 1
prisma/schema.prisma

@@ -71,7 +71,7 @@ model UserKeycloak {
71 71
 
72 72
 model Province {
73 73
   id         String     @id @default(uuid())
74
-  name       String     @unique
74
+  name       String
75 75
   cities     City[]
76 76
   hospitals  Hospital[]
77 77
   user_areas UserArea[]

+ 0 - 97
prisma/seeders/DatabaseSeeder.js

@@ -1,97 +0,0 @@
1
-const prisma = require('../../src/prisma/PrismaClient.js');
2
-
3
-const { seedProvinces } = require('./ProvinceSeeder');
4
-const { seedAcehCities } = require('./city/AcehCitySeeder');
5
-const { seedBaliCities } = require('./city/BaliCitySeeder');
6
-const { seedBantenCities } = require('./city/BantenCitySeeder');
7
-const { seedBengkuluCities } = require('./city/BengkuluCitySeeder');
8
-const { seedDIYogyakartaCities } = require('./city/DIYogyakartaCitySeeder');
9
-const { seedDKIJakartaCities } = require('./city/DKIJakartaCitySeeder');
10
-const { seedGorontaloCities } = require('./city/GorontaloCitySeeder');
11
-const { seedJambiCities } = require('./city/JambiCitySeeder');
12
-const { seedJawaBaratCities } = require('./city/JawaBaratCitySeeder');
13
-const { seedJawaTengahCities } = require('./city/JawaTengahCitySeeder');
14
-const { seedJawaTimurCities } = require('./city/JawaTimurCitySeeder');
15
-const { seedKalimantanBaratCities } = require('./city/KalimantanBaratCitySeeder');
16
-const { seedKalimantanSelatanCities } = require('./city/KalimantanSelatanCitySeeder');
17
-const { seedKalimantanTengahCities } = require('./city/KalimantanTengahCitySeeder');
18
-const { seedKalimantanTimurCities } = require('./city/KalimantanTimurCitySeeder');
19
-const { seedKalimantanUtaraCities } = require('./city/KalimantanUtaraCitySeeder');
20
-const { seedKepulauanBangkaBelitungCities } = require('./city/KepulauanBangkaBelitungCitySeeder');
21
-const { seedKepulauanRiauCities } = require('./city/KepulauanRiauCitySeeder');
22
-const { seedLampungCities } = require('./city/LampungCitySeeder');
23
-const { seedMalukuCities } = require('./city/MalukuCitySeeder');
24
-const { seedMalukuUtaraCities } = require('./city/MalukuUtaraCitySeeder');
25
-const { seedNusaTenggaraBaratCities } = require('./city/NusaTenggaraBaratCitySeeder');
26
-const { seedNusaTenggaraTimurCities } = require('./city/NusaTenggaraTimurCitySeeder');
27
-const { seedPapuaCities } = require('./city/PapuaCitySeeder');
28
-const { seedPapuaBaratCities } = require('./city/PapuaBaratCitySeeder');
29
-const { seedPapuaBaratDayaCities } = require('./city/PapuaBaratDayaCitySeeder');
30
-const { seedPapuaPegununganCities } = require('./city/PapuaPegununganCitySeeder');
31
-const { seedPapuaTengahCities } = require('./city/PapuaTengahCitySeeder');
32
-const { seedRiauCities } = require('./city/RiauCitySeeder');
33
-const { seedSulawesiBaratCities } = require('./city/SulawesiBaratCitySeeder');
34
-const { seedSulawesiSelatanCities } = require('./city/SulawesiSelatanCitySeeder');
35
-const { seedSulawesiTengahCities } = require('./city/SulawesiTengahCitySeeder');
36
-const { seedSulawesiTenggaraCities } = require('./city/SulawesiTenggaraCitySeeder');
37
-const { seedSulawesiUtaraCities } = require('./city/SulawesiUtaraCitySeeder');
38
-const { seedSumateraBaratCities } = require('./city/SumateraBaratCitySeeder');
39
-const { seedSumateraSelatanCities } = require('./city/SumateraSelatanCitySeeder');
40
-const { seedSumateraUtaraCities } = require('./city/SumateraUtaraCitySeeder');
41
-const { seedUsers } = require('./UserSeeder.js');
42
-// const { seedVendors } = require('./VendorSeeder.js');
43
-// const seedUserAreas = require('./UserAreaSeeder.js');
44
-// const { seedHospitals } = require('./HospitalSeeder.js');
45
-
46
-async function main() {
47
-    await seedProvinces();
48
-    await seedAcehCities();
49
-    await seedBaliCities();
50
-    await seedBantenCities();
51
-    await seedBengkuluCities();
52
-    await seedDIYogyakartaCities();
53
-    await seedDKIJakartaCities();
54
-    await seedGorontaloCities();
55
-    await seedJambiCities();
56
-    await seedJawaBaratCities();
57
-    await seedJawaTengahCities();
58
-    await seedJawaTimurCities();
59
-    await seedKalimantanBaratCities();
60
-    await seedKalimantanSelatanCities();
61
-    await seedKalimantanTengahCities();
62
-    await seedKalimantanTimurCities();
63
-    await seedKalimantanUtaraCities();
64
-    await seedKepulauanBangkaBelitungCities();
65
-    await seedKepulauanRiauCities();
66
-    await seedLampungCities();
67
-    await seedMalukuCities();
68
-    await seedMalukuUtaraCities();
69
-    await seedNusaTenggaraBaratCities();
70
-    await seedNusaTenggaraTimurCities();
71
-    await seedPapuaCities();
72
-    await seedPapuaBaratCities();
73
-    await seedPapuaBaratDayaCities();
74
-    await seedPapuaPegununganCities();
75
-    await seedPapuaTengahCities();
76
-    await seedRiauCities();
77
-    await seedSulawesiBaratCities();
78
-    await seedSulawesiSelatanCities();
79
-    await seedSulawesiTengahCities();
80
-    await seedSulawesiTenggaraCities();
81
-    await seedSulawesiUtaraCities();
82
-    await seedSumateraBaratCities();
83
-    await seedSumateraSelatanCities();
84
-    await seedSumateraUtaraCities();
85
-    await seedUsers();
86
-    // await seedUserAreas();
87
-    // await seedHospitals();
88
-    // await seedVendors();
89
-}
90
-
91
-main().then(() => {
92
-    console.log('✅ Seeding completed');
93
-    return prisma.$disconnect();
94
-}).catch((e) => {
95
-    console.error('❌ Seeding error:', e);
96
-    return prisma.$disconnect().then(() => process.exit(1));
97
-});

+ 101 - 0
prisma/seeders/DatabaseSeeder.ts

@@ -0,0 +1,101 @@
1
+import prisma from '../../src/prisma/PrismaClient';
2
+import { seedProvinces } from './ProvinceSeeder';
3
+import { seedAcehCities } from './city/AcehCitySeeder';
4
+import { seedBaliCities } from './city/BaliCitySeeder';
5
+import { seedBantenCities } from './city/BantenCitySeeder';
6
+import { seedBengkuluCities } from './city/BengkuluCitySeeder';
7
+import { seedDIYogyakartaCities } from './city/DIYogyakartaCitySeeder';
8
+import { seedDKIJakartaCities } from './city/DKIJakartaCitySeeder';
9
+import { seedGorontaloCities } from './city/GorontaloCitySeeder';
10
+import { seedJambiCities } from './city/JambiCitySeeder';
11
+import { seedJawaBaratCities } from './city/JawaBaratCitySeeder';
12
+import { seedJawaTengahCities } from './city/JawaTengahCitySeeder';
13
+import { seedJawaTimurCities } from './city/JawaTimurCitySeeder';
14
+import { seedKalimantanBaratCities } from './city/KalimantanBaratCitySeeder';
15
+import { seedKalimantanSelatanCities } from './city/KalimantanSelatanCitySeeder';
16
+import { seedKalimantanTengahCities } from './city/KalimantanTengahCitySeeder';
17
+import { seedKalimantanTimurCities } from './city/KalimantanTimurCitySeeder';
18
+import { seedKalimantanUtaraCities } from './city/KalimantanUtaraCitySeeder';
19
+import { seedKepulauanBangkaBelitungCities } from './city/KepulauanBangkaBelitungCitySeeder';
20
+import { seedKepulauanRiauCities } from './city/KepulauanRiauCitySeeder';
21
+import { seedLampungCities } from './city/LampungCitySeeder';
22
+import { seedMalukuCities } from './city/MalukuCitySeeder';
23
+import { seedMalukuUtaraCities } from './city/MalukuUtaraCitySeeder';
24
+import { seedNusaTenggaraBaratCities } from './city/NusaTenggaraBaratCitySeeder';
25
+import { seedNusaTenggaraTimurCities } from './city/NusaTenggaraTimurCitySeeder';
26
+import { seedPapuaCities } from './city/PapuaCitySeeder';
27
+import { seedPapuaBaratCities } from './city/PapuaBaratCitySeeder';
28
+import { seedPapuaBaratDayaCities } from './city/PapuaBaratDayaCitySeeder';
29
+import { seedPapuaPegununganCities } from './city/PapuaPegununganCitySeeder';
30
+import { seedPapuaTengahCities } from './city/PapuaTengahCitySeeder';
31
+import { seedRiauCities } from './city/RiauCitySeeder';
32
+import { seedSulawesiBaratCities } from './city/SulawesiBaratCitySeeder';
33
+import { seedSulawesiSelatanCities } from './city/SulawesiSelatanCitySeeder';
34
+import { seedSulawesiTengahCities } from './city/SulawesiTengahCitySeeder';
35
+import { seedSulawesiTenggaraCities } from './city/SulawesiTenggaraCitySeeder';
36
+import { seedSulawesiUtaraCities } from './city/SulawesiUtaraCitySeeder';
37
+import { seedSumateraBaratCities } from './city/SumateraBaratCitySeeder';
38
+import { seedSumateraSelatanCities } from './city/SumateraSelatanCitySeeder';
39
+import { seedSumateraUtaraCities } from './city/SumateraUtaraCitySeeder';
40
+import { seedPapuaSelatanCities } from './city/PapuaSelatanCitySeeder';
41
+import { seedUsers } from './UserSeeder';
42
+import { seedVendors } from './VendorSeeder';
43
+import { seedUserAreas } from './UserAreaSeeder';
44
+import { seedHospitals } from './HospitalSeeder';
45
+
46
+async function main(): Promise<void> {
47
+    await seedProvinces();
48
+    await seedAcehCities();
49
+    await seedBaliCities();
50
+    await seedBantenCities();
51
+    await seedBengkuluCities();
52
+    await seedDIYogyakartaCities();
53
+    await seedDKIJakartaCities();
54
+    await seedGorontaloCities();
55
+    await seedJambiCities();
56
+    await seedJawaBaratCities();
57
+    await seedJawaTengahCities();
58
+    await seedJawaTimurCities();
59
+    await seedKalimantanBaratCities();
60
+    await seedKalimantanSelatanCities();
61
+    await seedKalimantanTengahCities();
62
+    await seedKalimantanTimurCities();
63
+    await seedKalimantanUtaraCities();
64
+    await seedKepulauanBangkaBelitungCities();
65
+    await seedKepulauanRiauCities();
66
+    await seedLampungCities();
67
+    await seedMalukuCities();
68
+    await seedMalukuUtaraCities();
69
+    await seedNusaTenggaraBaratCities();
70
+    await seedNusaTenggaraTimurCities();
71
+    await seedPapuaCities();
72
+    await seedPapuaBaratCities();
73
+    await seedPapuaBaratDayaCities();
74
+    await seedPapuaPegununganCities();
75
+    await seedPapuaTengahCities();
76
+    await seedRiauCities();
77
+    await seedSulawesiBaratCities();
78
+    await seedSulawesiSelatanCities();
79
+    await seedSulawesiTengahCities();
80
+    await seedSulawesiTenggaraCities();
81
+    await seedSulawesiUtaraCities();
82
+    await seedSumateraBaratCities();
83
+    await seedSumateraSelatanCities();
84
+    await seedSumateraUtaraCities();
85
+    await seedPapuaSelatanCities();
86
+    await seedUsers();
87
+    // await seedVendors();
88
+    // await seedUserAreas();
89
+    // await seedHospitals();
90
+}
91
+
92
+main()
93
+    .then(async () => {
94
+        console.log('✅ Seeding completed');
95
+        await prisma.$disconnect();
96
+    })
97
+    .catch(async (e: unknown) => {
98
+        console.error('❌ Seeding error:', e);
99
+        await prisma.$disconnect();
100
+        process.exit(1);
101
+    });

+ 0 - 146
prisma/seeders/HospitalSeeder.js

@@ -1,146 +0,0 @@
1
-const { PrismaClient } = require('@prisma/client');
2
-const prisma = new PrismaClient();
3
-
4
-async function seedHospitals() {
5
-    try {
6
-        const sales1 = await prisma.userKeycloak.findFirst({ where: { id: '26042443-e53a-44b1-ab52-12985e8bdad1' } });
7
-        const sales2 = await prisma.userKeycloak.findFirst({ where: { id: '49349b07-a46c-4686-a964-8bbcedbf63f2' } });
8
-
9
-        if (!sales1 || !sales2) {
10
-            throw new Error('User sales1 or sales2 not found');
11
-        }
12
-
13
-        // Ambil province_id dari user_areas
14
-        const sales1Area = await prisma.userArea.findFirst({ where: { user_id: sales1.id } });
15
-        const sales2Area = await prisma.userArea.findFirst({ where: { user_id: sales2.id } });
16
-
17
-        if (!sales1Area || !sales2Area) {
18
-            throw new Error('UserArea for sales1 or sales2 not found');
19
-        }
20
-
21
-        // Ambil city yang berada di province_id tersebut
22
-        const city1 = await prisma.city.findFirst({ where: { province_id: sales1Area.province_id } });
23
-        const city2 = await prisma.city.findFirst({ where: { province_id: sales2Area.province_id } });
24
-
25
-        if (!city1 || !city2) {
26
-            throw new Error('City not found for one of province id');
27
-        }
28
-
29
-        // Data rumah sakit
30
-        const hospitals = [
31
-            {
32
-                name: 'RS Sehat Selalu',
33
-                hospital_code: 'RSS001',
34
-                type: 'Tipe B',
35
-                ownership: 'Swasta',
36
-                address: 'Jl. Kesehatan No. 1',
37
-                // simrs_type: 'MediSoft',
38
-                contact: '021-123456',
39
-                image: null,
40
-                progress_status: 'cari_data',
41
-                note: 'Calon potensial',
42
-                province_id: sales1Area.province_id,
43
-                city_id: city1.id,
44
-                created_by: sales1.id,
45
-            },
46
-            {
47
-                name: 'RS Harapan Bangsa',
48
-                hospital_code: 'RSB002',
49
-                type: 'Tipe C',
50
-                ownership: 'Pemerintah',
51
-                address: 'Jl. Harapan No. 2',
52
-                // simrs_type: 'Hospicare',
53
-                contact: '021-654321',
54
-                image: null,
55
-                progress_status: 'cari_data',
56
-                note: null,
57
-                province_id: sales1Area.province_id,
58
-                city_id: city1.id,
59
-                created_by: sales1.id,
60
-            },
61
-            {
62
-                name: 'RS Mitra Medika',
63
-                hospital_code: 'RSM003',
64
-                type: 'Tipe D',
65
-                ownership: 'Swasta',
66
-                address: 'Jl. Mitra No. 3',
67
-                // simrs_type: 'SimRS Platinum',
68
-                contact: '021-999999',
69
-                image: null,
70
-                progress_status: 'cari_data',
71
-                note: 'Baru dihubungi',
72
-                province_id: sales1Area.province_id,
73
-                city_id: city1.id,
74
-                created_by: sales1.id,
75
-            },
76
-            {
77
-                name: 'RS Sembuh Bersama',
78
-                hospital_code: 'RSB004',
79
-                type: 'Tipe B',
80
-                ownership: 'Swasta',
81
-                address: 'Jl. Bersama No. 4',
82
-                // simrs_type: 'MediSoft',
83
-                contact: '0274-111111',
84
-                image: null,
85
-                progress_status: 'cari_data',
86
-                note: null,
87
-                province_id: sales2Area.province_id,
88
-                city_id: city2.id,
89
-                created_by: sales2.id,
90
-            },
91
-            {
92
-                name: 'RS Kasih Ibu',
93
-                hospital_code: 'RSK005',
94
-                type: 'Tipe C',
95
-                ownership: 'Yayasan',
96
-                address: 'Jl. Kasih No. 5',
97
-                // simrs_type: 'Hospicare',
98
-                contact: '0274-222222',
99
-                image: null,
100
-                progress_status: 'cari_data',
101
-                note: 'Perlu follow up',
102
-                province_id: sales2Area.province_id,
103
-                city_id: city2.id,
104
-                created_by: sales2.id,
105
-            },
106
-            {
107
-                name: 'RS Bhakti Sehat',
108
-                hospital_code: 'RSB006',
109
-                type: 'Tipe D',
110
-                ownership: 'Swasta',
111
-                address: 'Jl. Bhakti No. 6',
112
-                // simrs_type: 'SimRS Platinum',
113
-                contact: '0274-333333',
114
-                image: null,
115
-                progress_status: 'cari_data',
116
-                note: null,
117
-                province_id: sales2Area.province_id,
118
-                city_id: city2.id,
119
-                created_by: sales2.id,
120
-            },
121
-        ];
122
-
123
-        // Masukkan ke DB
124
-        for (const hospital of hospitals) {
125
-            await prisma.hospital.create({ data: hospital });
126
-        }
127
-
128
-        console.log('✅ Hospital seeded!');
129
-    } catch (err) {
130
-        console.error('❌ Error seeding hospital:', err.message);
131
-    }
132
-}
133
-
134
-module.exports = { seedHospitals };
135
-
136
-if (require.main === module) {
137
-    seedHospitals()
138
-        .then(() => {
139
-            console.log('🌱 Seeder selesai!');
140
-            process.exit(0);
141
-        })
142
-        .catch((err) => {
143
-            console.error('❌ Error saat seeding:', err);
144
-            process.exit(1);
145
-        });
146
-}

+ 261 - 0
prisma/seeders/HospitalSeeder.ts

@@ -0,0 +1,261 @@
1
+import { PrismaClient } from '@prisma/client';
2
+import { ProgressStatus } from '@prisma/client';
3
+
4
+const prisma = new PrismaClient();
5
+
6
+export async function seedHospitals(): Promise<void> {
7
+    try {
8
+        const sales1 = await prisma.userKeycloak.findFirst({ where: { id: '1b50e497-159f-49c2-aa4d-466e72d796f0' } });
9
+        const sales2 = await prisma.userKeycloak.findFirst({ where: { id: '0ec065d8-547c-46e3-9980-df36b9648767' } });
10
+
11
+        if (!sales1 || !sales2) {
12
+            throw new Error('User sales1 or sales2 not found');
13
+        }
14
+
15
+        const sales1Area = await prisma.userArea.findFirst({ where: { user_id: sales1.id } });
16
+        const sales2Area = await prisma.userArea.findFirst({ where: { user_id: sales2.id } });
17
+
18
+        if (!sales1Area || !sales2Area) {
19
+            throw new Error('UserArea for sales1 or sales2 not found');
20
+        }
21
+
22
+        const city1 = await prisma.city.findFirst({ where: { province_id: sales1Area.province_id } });
23
+        const city2 = await prisma.city.findFirst({ where: { province_id: sales2Area.province_id } });
24
+
25
+        if (!city1 || !city2) {
26
+            throw new Error('City not found for one of province id');
27
+        }
28
+
29
+        const hospitals = [
30
+            {
31
+                name: 'RS Sehat Selalu',
32
+                hospital_code: 'RSS001',
33
+                type: 'Tipe B',
34
+                ownership: 'Swasta',
35
+                address: 'Jl. Kesehatan No. 1',
36
+                contact: '021-123456',
37
+                image: null,
38
+                progress_status: ProgressStatus.cari_data,
39
+                note: 'Calon potensial',
40
+                province_id: sales1Area.province_id,
41
+                city_id: city1.id,
42
+                created_by: sales1.id,
43
+            },
44
+            {
45
+                name: 'RS Harapan Bangsa',
46
+                hospital_code: 'RSB002',
47
+                type: 'Tipe C',
48
+                ownership: 'Pemerintah',
49
+                address: 'Jl. Harapan No. 2',
50
+                contact: '021-654321',
51
+                image: null,
52
+                progress_status: ProgressStatus.cari_data,
53
+                note: null,
54
+                province_id: sales1Area.province_id,
55
+                city_id: city1.id,
56
+                created_by: sales1.id,
57
+            },
58
+            {
59
+                name: 'RS Mitra Medika',
60
+                hospital_code: 'RSM003',
61
+                type: 'Tipe D',
62
+                ownership: 'Swasta',
63
+                address: 'Jl. Mitra No. 3',
64
+                contact: '021-999999',
65
+                image: null,
66
+                progress_status: ProgressStatus.cari_data,
67
+                note: 'Baru dihubungi',
68
+                province_id: sales1Area.province_id,
69
+                city_id: city1.id,
70
+                created_by: sales1.id,
71
+            },
72
+            {
73
+                name: 'RS Sembuh Bersama',
74
+                hospital_code: 'RSB004',
75
+                type: 'Tipe B',
76
+                ownership: 'Swasta',
77
+                address: 'Jl. Bersama No. 4',
78
+                contact: '0274-111111',
79
+                image: null,
80
+                progress_status: ProgressStatus.cari_data,
81
+                note: null,
82
+                province_id: sales2Area.province_id,
83
+                city_id: city2.id,
84
+                created_by: sales2.id,
85
+            },
86
+            {
87
+                name: 'RS Kasih Ibu',
88
+                hospital_code: 'RSK005',
89
+                type: 'Tipe C',
90
+                ownership: 'Yayasan',
91
+                address: 'Jl. Kasih No. 5',
92
+                contact: '0274-222222',
93
+                image: null,
94
+                progress_status: ProgressStatus.cari_data,
95
+                note: 'Perlu follow up',
96
+                province_id: sales2Area.province_id,
97
+                city_id: city2.id,
98
+                created_by: sales2.id,
99
+            },
100
+            {
101
+                name: 'RS Bhakti Sehat',
102
+                hospital_code: 'RSB006',
103
+                type: 'Tipe D',
104
+                ownership: 'Swasta',
105
+                address: 'Jl. Bhakti No. 6',
106
+                contact: '0274-333333',
107
+                image: null,
108
+                progress_status: ProgressStatus.cari_data,
109
+                note: null,
110
+                province_id: sales2Area.province_id,
111
+                city_id: city2.id,
112
+                created_by: sales2.id,
113
+            },
114
+        ];
115
+
116
+        for (const hospital of hospitals) {
117
+            await prisma.hospital.create({ data: hospital });
118
+        }
119
+
120
+        console.log('✅ Hospital seeded!');
121
+    } catch (err: any) {
122
+        console.error('❌ Error seeding hospital:', err.message);
123
+    }
124
+}
125
+
126
+seedHospitals();
127
+
128
+// const { PrismaClient } = require('@prisma/client');
129
+// const prisma = new PrismaClient();
130
+
131
+// async function seedHospitals() {
132
+//     try {
133
+//         const sales1 = await prisma.user.findFirst({ where: { username: 'sales1' } });
134
+//         const sales2 = await prisma.user.findFirst({ where: { username: 'sales2' } });
135
+
136
+//         if (!sales1 || !sales2) {
137
+//             throw new Error('User sales1 or sales2 not found');
138
+//         }
139
+
140
+//         // Ambil province_id dari user_areas
141
+//         const sales1Area = await prisma.userArea.findFirst({ where: { user_id: sales1.id } });
142
+//         const sales2Area = await prisma.userArea.findFirst({ where: { user_id: sales2.id } });
143
+
144
+//         if (!sales1Area || !sales2Area) {
145
+//             throw new Error('UserArea for sales1 or sales2 not found');
146
+//         }
147
+
148
+//         // Ambil city yang berada di province_id tersebut
149
+//         const city1 = await prisma.city.findFirst({ where: { province_id: sales1Area.province_id } });
150
+//         const city2 = await prisma.city.findFirst({ where: { province_id: sales2Area.province_id } });
151
+
152
+//         if (!city1 || !city2) {
153
+//             throw new Error('City not found for one of province id');
154
+//         }
155
+
156
+//         // Data rumah sakit
157
+//         const hospitals = [
158
+//             {
159
+//                 name: 'RS Sehat Selalu',
160
+//                 hospital_code: 'RSS001',
161
+//                 type: 'Tipe B',
162
+//                 ownership: 'Swasta',
163
+//                 address: 'Jl. Kesehatan No. 1',
164
+//                 // simrs_type: 'MediSoft',
165
+//                 contact: '021-123456',
166
+//                 image: null,
167
+//                 progress_status: 'cari_data',
168
+//                 note: 'Calon potensial',
169
+//                 province_id: sales1Area.province_id,
170
+//                 city_id: city1.id,
171
+//                 created_by: sales1.id,
172
+//             },
173
+//             {
174
+//                 name: 'RS Harapan Bangsa',
175
+//                 hospital_code: 'RSB002',
176
+//                 type: 'Tipe C',
177
+//                 ownership: 'Pemerintah',
178
+//                 address: 'Jl. Harapan No. 2',
179
+//                 // simrs_type: 'Hospicare',
180
+//                 contact: '021-654321',
181
+//                 image: null,
182
+//                 progress_status: 'cari_data',
183
+//                 note: null,
184
+//                 province_id: sales1Area.province_id,
185
+//                 city_id: city1.id,
186
+//                 created_by: sales1.id,
187
+//             },
188
+//             {
189
+//                 name: 'RS Mitra Medika',
190
+//                 hospital_code: 'RSM003',
191
+//                 type: 'Tipe D',
192
+//                 ownership: 'Swasta',
193
+//                 address: 'Jl. Mitra No. 3',
194
+//                 // simrs_type: 'SimRS Platinum',
195
+//                 contact: '021-999999',
196
+//                 image: null,
197
+//                 progress_status: 'cari_data',
198
+//                 note: 'Baru dihubungi',
199
+//                 province_id: sales1Area.province_id,
200
+//                 city_id: city1.id,
201
+//                 created_by: sales1.id,
202
+//             },
203
+//             {
204
+//                 name: 'RS Sembuh Bersama',
205
+//                 hospital_code: 'RSB004',
206
+//                 type: 'Tipe B',
207
+//                 ownership: 'Swasta',
208
+//                 address: 'Jl. Bersama No. 4',
209
+//                 // simrs_type: 'MediSoft',
210
+//                 contact: '0274-111111',
211
+//                 image: null,
212
+//                 progress_status: 'cari_data',
213
+//                 note: null,
214
+//                 province_id: sales2Area.province_id,
215
+//                 city_id: city2.id,
216
+//                 created_by: sales2.id,
217
+//             },
218
+//             {
219
+//                 name: 'RS Kasih Ibu',
220
+//                 hospital_code: 'RSK005',
221
+//                 type: 'Tipe C',
222
+//                 ownership: 'Yayasan',
223
+//                 address: 'Jl. Kasih No. 5',
224
+//                 // simrs_type: 'Hospicare',
225
+//                 contact: '0274-222222',
226
+//                 image: null,
227
+//                 progress_status: 'cari_data',
228
+//                 note: 'Perlu follow up',
229
+//                 province_id: sales2Area.province_id,
230
+//                 city_id: city2.id,
231
+//                 created_by: sales2.id,
232
+//             },
233
+//             {
234
+//                 name: 'RS Bhakti Sehat',
235
+//                 hospital_code: 'RSB006',
236
+//                 type: 'Tipe D',
237
+//                 ownership: 'Swasta',
238
+//                 address: 'Jl. Bhakti No. 6',
239
+//                 // simrs_type: 'SimRS Platinum',
240
+//                 contact: '0274-333333',
241
+//                 image: null,
242
+//                 progress_status: 'cari_data',
243
+//                 note: null,
244
+//                 province_id: sales2Area.province_id,
245
+//                 city_id: city2.id,
246
+//                 created_by: sales2.id,
247
+//             },
248
+//         ];
249
+
250
+//         // Masukkan ke DB
251
+//         for (const hospital of hospitals) {
252
+//             await prisma.hospital.create({ data: hospital });
253
+//         }
254
+
255
+//         console.log('✅ Hospital seeded!');
256
+//     } catch (err) {
257
+//         console.error('❌ Error seeding hospital:', err.message);
258
+//     }
259
+// }
260
+
261
+// module.exports = { seedHospitals };

+ 0 - 30
prisma/seeders/ProvinceSeeder.js

@@ -1,30 +0,0 @@
1
-const prisma = require('../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../src/utils/TimeLocal.js')
3
-
4
-const provinces = [
5
-    "Aceh", "Bali", "Banten", "Bengkulu", "DI Yogyakarta", "DKI Jakarta", "Gorontalo",
6
-    "Jambi", "Jawa Barat", "Jawa Tengah", "Jawa Timur", "Kalimantan Barat",
7
-    "Kalimantan Selatan", "Kalimantan Tengah", "Kalimantan Timur", "Kalimantan Utara",
8
-    "Kepulauan Bangka Belitung", "Kepulauan Riau", "Lampung", "Maluku",
9
-    "Maluku Utara", "Nusa Tenggara Barat", "Nusa Tenggara Timur", "Papua",
10
-    "Papua Barat", "Papua Barat Daya", "Papua Pegunungan", "Papua Selatan",
11
-    "Papua Tengah", "Riau", "Sulawesi Barat", "Sulawesi Selatan", "Sulawesi Tengah",
12
-    "Sulawesi Tenggara", "Sulawesi Utara", "Sumatera Barat", "Sumatera Selatan", "Sumatera Utara"
13
-];
14
-
15
-exports.seedProvinces = async () => {
16
-    for (const name of provinces.sort()) {
17
-        await prisma.province.upsert({
18
-            where: { name },
19
-            create: {
20
-                name,
21
-                createdAt: timeLocal.now().toDate(),
22
-            },
23
-            update: {
24
-                updatedAt: timeLocal.now().toDate()
25
-            }
26
-        });
27
-    }
28
-
29
-    console.log('✅ Provinces seeded!');
30
-};

+ 41 - 0
prisma/seeders/ProvinceSeeder.ts

@@ -0,0 +1,41 @@
1
+import prisma from '../../src/prisma/PrismaClient';
2
+import { now } from '../../src/utils/TimeLocal';
3
+
4
+const provinces: string[] = [
5
+    "Aceh", "Bali", "Banten", "Bengkulu", "DI Yogyakarta", "DKI Jakarta", "Gorontalo",
6
+    "Jambi", "Jawa Barat", "Jawa Tengah", "Jawa Timur", "Kalimantan Barat",
7
+    "Kalimantan Selatan", "Kalimantan Tengah", "Kalimantan Timur", "Kalimantan Utara",
8
+    "Kepulauan Bangka Belitung", "Kepulauan Riau", "Lampung", "Maluku",
9
+    "Maluku Utara", "Nusa Tenggara Barat", "Nusa Tenggara Timur", "Papua",
10
+    "Papua Barat", "Papua Barat Daya", "Papua Pegunungan", "Papua Selatan",
11
+    "Papua Tengah", "Riau", "Sulawesi Barat", "Sulawesi Selatan", "Sulawesi Tengah",
12
+    "Sulawesi Tenggara", "Sulawesi Utara", "Sumatera Barat", "Sumatera Selatan", "Sumatera Utara"
13
+];
14
+
15
+export async function seedProvinces(): Promise<void> {
16
+    for (const name of provinces.sort()) {
17
+        const existing = await prisma.province.findFirst({
18
+            where: { name },
19
+        });
20
+
21
+        if (!existing || existing.deletedAt !== null) {
22
+            // Jika tidak ada atau sudah soft-deleted, buat baru
23
+            await prisma.province.create({
24
+                data: {
25
+                    name,
26
+                    createdAt: now().toDate(),
27
+                },
28
+            });
29
+        } else {
30
+            // Jika sudah ada dan aktif, update updatedAt saja (optional)
31
+            await prisma.province.update({
32
+                where: { id: existing.id },
33
+                data: {
34
+                    updatedAt: now().toDate(),
35
+                },
36
+            });
37
+        }
38
+    }
39
+
40
+    console.log('✅ Provinces seeded!');
41
+}

+ 0 - 53
prisma/seeders/UserAreaSeeder.js

@@ -1,53 +0,0 @@
1
-const prisma = require('../../src/prisma/PrismaClient.js');
2
-
3
-async function seedUserAreas() {
4
-    try {
5
-        // Ambil user dengan role 'sales1' dan 'sales2'
6
-        const sales1 = await prisma.userKeycloak.findFirst({ where: { id: '26042443-e53a-44b1-ab52-12985e8bdad1' } });
7
-        const sales2 = await prisma.userKeycloak.findFirst({ where: { id: '49349b07-a46c-4686-a964-8bbcedbf63f2' } });
8
-
9
-        if (!sales1 || !sales2) {
10
-            throw new Error('User sales1 or sales2 not found');
11
-        }
12
-
13
-        // Ambil provinsi
14
-        const jawaTengah = await prisma.province.findFirst({ where: { name: 'Jawa Tengah' } });
15
-        const diy = await prisma.province.findFirst({ where: { name: 'DI Yogyakarta' } });
16
-
17
-        if (!jawaTengah || !diy) {
18
-            throw new Error('Province Jawa Tengah or DI Yogyakarta not found');
19
-        }
20
-
21
-        // Buat user_areas
22
-        await prisma.userArea.createMany({
23
-            data: [
24
-                {
25
-                    user_id: sales1.id,
26
-                    province_id: jawaTengah.id,
27
-                },
28
-                {
29
-                    user_id: sales2.id,
30
-                    province_id: diy.id,
31
-                },
32
-            ],
33
-        });
34
-
35
-        console.log('✅ User area seeded');
36
-    } catch (error) {
37
-        console.error('❌ Error seeding user area:', error);
38
-    }
39
-}
40
-
41
-module.exports = seedUserAreas;
42
-
43
-if (require.main === module) {
44
-    seedUserAreas()
45
-        .then(() => {
46
-            console.log('🌱 Seeder selesai!');
47
-            process.exit(0);
48
-        })
49
-        .catch((err) => {
50
-            console.error('❌ Error saat seeding:', err);
51
-            process.exit(1);
52
-        });
53
-}

+ 84 - 0
prisma/seeders/UserAreaSeeder.ts

@@ -0,0 +1,84 @@
1
+import prisma from '../../src/prisma/PrismaClient';
2
+
3
+export async function seedUserAreas(): Promise<void> {
4
+    try {
5
+        // Ambil user dengan username 'sales1' dan 'sales2'
6
+        const sales1 = await prisma.userKeycloak.findFirst({ where: { id: '1b50e497-159f-49c2-aa4d-466e72d796f0' } });
7
+        const sales2 = await prisma.userKeycloak.findFirst({ where: { id: '0ec065d8-547c-46e3-9980-df36b9648767' } });
8
+
9
+        if (!sales1 || !sales2) {
10
+            throw new Error('User sales1 or sales2 not found');
11
+        }
12
+
13
+        // Ambil provinsi
14
+        const jawaTengah = await prisma.province.findFirst({ where: { name: 'Jawa Tengah' } });
15
+        const diy = await prisma.province.findFirst({ where: { name: 'DI Yogyakarta' } });
16
+
17
+        if (!jawaTengah || !diy) {
18
+            throw new Error('Province Jawa Tengah or DI Yogyakarta not found');
19
+        }
20
+
21
+        // Buat data user_area
22
+        await prisma.userArea.createMany({
23
+            data: [
24
+                {
25
+                    user_id: sales1.id,
26
+                    province_id: jawaTengah.id,
27
+                },
28
+                {
29
+                    user_id: sales2.id,
30
+                    province_id: diy.id,
31
+                },
32
+            ],
33
+        });
34
+
35
+        console.log('✅ User area seeded');
36
+    } catch (error: any) {
37
+        console.error('❌ Error seeding user area:', error.message);
38
+    }
39
+}
40
+
41
+seedUserAreas();
42
+
43
+
44
+// const prisma = require('../../src/prisma/PrismaClient.js');
45
+
46
+// async function seedUserAreas() {
47
+//     try {
48
+//         // Ambil user dengan role 'sales1' dan 'sales2'
49
+//         const sales1 = await prisma.user.findFirst({ where: { username: 'sales1' } });
50
+//         const sales2 = await prisma.user.findFirst({ where: { username: 'sales2' } });
51
+
52
+//         if (!sales1 || !sales2) {
53
+//             throw new Error('User sales1 or sales2 not found');
54
+//         }
55
+
56
+//         // Ambil provinsi
57
+//         const jawaTengah = await prisma.province.findFirst({ where: { name: 'Jawa Tengah' } });
58
+//         const diy = await prisma.province.findFirst({ where: { name: 'DI Yogyakarta' } });
59
+
60
+//         if (!jawaTengah || !diy) {
61
+//             throw new Error('Province Jawa Tengah or DI Yogyakarta not found');
62
+//         }
63
+
64
+//         // Buat user_areas
65
+//         await prisma.userArea.createMany({
66
+//             data: [
67
+//                 {
68
+//                     user_id: sales1.id,
69
+//                     province_id: jawaTengah.id,
70
+//                 },
71
+//                 {
72
+//                     user_id: sales2.id,
73
+//                     province_id: diy.id,
74
+//                 },
75
+//             ],
76
+//         });
77
+
78
+//         console.log('✅ User area seeded');
79
+//     } catch (error) {
80
+//         console.error('❌ Error seeding user area:', error);
81
+//     }
82
+// }
83
+
84
+// module.exports = seedUserAreas;

+ 0 - 148
prisma/seeders/UserSeeder.js

@@ -1,148 +0,0 @@
1
-const axios = require('axios');
2
-const qs = require('qs');
3
-const bcrypt = require('bcrypt');
4
-const prisma = require('../../src/prisma/PrismaClient.js');
5
-const {
6
-    KEYCLOAK_TOKEN_URL,
7
-    KEYCLOAK_ADMIN_URL,
8
-    KEYCLOAK_REALM,
9
-    CLIENT_ID,
10
-    CLIENT_SECRET,
11
-} = require('../../config/keycloak.js');
12
-
13
-// Ambil token admin Keycloak
14
-const getAdminToken = async () => {
15
-    const tokenParams = qs.stringify({
16
-        grant_type: 'client_credentials',
17
-        client_id: CLIENT_ID,
18
-        client_secret: CLIENT_SECRET,
19
-    });
20
-
21
-    const { data } = await axios.post(KEYCLOAK_TOKEN_URL, tokenParams, {
22
-        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
23
-    });
24
-
25
-    return data.access_token;
26
-};
27
-
28
-// Buat user di Keycloak
29
-const createUserInKeycloak = async (user, token) => {
30
-    const checkUser = await axios.get(
31
-        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users?username=${user.username}`,
32
-        { headers: { Authorization: `Bearer ${token}` } }
33
-    );
34
-
35
-    if (checkUser.data.length > 0) {
36
-        console.log(`⚠️  User ${user.username} found in Keycloak`);
37
-        return checkUser.data[0].id;
38
-    }
39
-
40
-    await axios.post(
41
-        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users`,
42
-        {
43
-            username: user.username,
44
-            email: user.email,
45
-            firstName: user.firstname,
46
-            lastName: user.lastname,
47
-            enabled: true,
48
-            credentials: [
49
-                {
50
-                    type: 'password',
51
-                    value: user.password,
52
-                    temporary: false,
53
-                },
54
-            ],
55
-        },
56
-        {
57
-            headers: { Authorization: `Bearer ${token}` },
58
-        }
59
-    );
60
-
61
-    const { data } = await axios.get(
62
-        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users?username=${user.username}`,
63
-        {
64
-            headers: { Authorization: `Bearer ${token}` },
65
-        }
66
-    );
67
-
68
-    return data[0].id;
69
-};
70
-
71
-// Assign role ke user di Keycloak
72
-const assignRole = async (userId, roleName, token) => {
73
-    const { data: roles } = await axios.get(
74
-        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/roles`,
75
-        {
76
-            headers: { Authorization: `Bearer ${token}` },
77
-        }
78
-    );
79
-
80
-    const role = roles.find((r) => r.name === roleName);
81
-    if (!role) throw new Error(`Role "${roleName}" not found in Keycloak`);
82
-
83
-    await axios.post(
84
-        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users/${userId}/role-mappings/realm`,
85
-        [role],
86
-        {
87
-            headers: { Authorization: `Bearer ${token}` },
88
-        }
89
-    );
90
-};
91
-
92
-// Data user yang ingin dibuat
93
-const users = [
94
-    {
95
-        username: 'admin1',
96
-        email: 'admin1@gmail.com',
97
-        password: 'password123',
98
-        firstname: 'Admin',
99
-        lastname: 'Satu',
100
-        role: 'admin',
101
-    },
102
-    {
103
-        username: 'sales1',
104
-        email: 'sales1@gmail.com',
105
-        password: 'password123',
106
-        firstname: 'Sales',
107
-        lastname: 'Satu',
108
-        role: 'sales',
109
-    },
110
-    {
111
-        username: 'sales2',
112
-        email: 'sales2@gmail.com',
113
-        password: 'password123',
114
-        firstname: 'Sales',
115
-        lastname: 'Dua',
116
-        role: 'sales',
117
-    },
118
-];
119
-
120
-// Fungsi utama yang bisa dipanggil dari seeder utama
121
-const seedUsers = async () => {
122
-    const token = await getAdminToken();
123
-
124
-    for (const user of users) {
125
-        const userId = await createUserInKeycloak(user, token);
126
-        await assignRole(userId, user.role, token);
127
-
128
-        const hashedPassword = await bcrypt.hash(user.password, 10);
129
-
130
-        await prisma.user.upsert({
131
-            where: { id: userId },
132
-            update: {},
133
-            create: {
134
-                id: userId,
135
-                username: user.username,
136
-                email: user.email,
137
-                firstname: user.firstname,
138
-                lastname: user.lastname,
139
-                password: hashedPassword,
140
-                role: user.role,
141
-            },
142
-        });
143
-
144
-        console.log(`✅ Success seed user ${user.role}: ${user.username}`);
145
-    }
146
-};
147
-
148
-module.exports = { seedUsers };

+ 306 - 0
prisma/seeders/UserSeeder.ts

@@ -0,0 +1,306 @@
1
+import axios from 'axios';
2
+import qs from 'qs';
3
+import bcrypt from 'bcrypt';
4
+import prisma from '../../src/prisma/PrismaClient';
5
+import {
6
+    KEYCLOAK_TOKEN_URL,
7
+    KEYCLOAK_ADMIN_URL,
8
+    KEYCLOAK_REALM,
9
+    CLIENT_ID,
10
+    CLIENT_SECRET,
11
+} from '../../config/keycloak';
12
+
13
+// Tipe untuk data user lokal
14
+interface SeedUser {
15
+    username: string;
16
+    email: string;
17
+    password: string;
18
+    firstname: string;
19
+    lastname: string;
20
+    role: string;
21
+}
22
+
23
+// Ambil token admin dari Keycloak
24
+const getAdminToken = async (): Promise<string> => {
25
+    const tokenParams = qs.stringify({
26
+        grant_type: 'client_credentials',
27
+        client_id: CLIENT_ID,
28
+        client_secret: CLIENT_SECRET,
29
+    });
30
+
31
+    const { data } = await axios.post(KEYCLOAK_TOKEN_URL, tokenParams, {
32
+        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
33
+    });
34
+
35
+    return data.access_token;
36
+};
37
+
38
+// Membuat user di Keycloak
39
+const createUserInKeycloak = async (user: SeedUser, token: string): Promise<string> => {
40
+    const checkUser = await axios.get(
41
+        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users?username=${user.username}`,
42
+        { headers: { Authorization: `Bearer ${token}` } }
43
+    );
44
+
45
+    if (checkUser.data.length > 0) {
46
+        console.log(`⚠️  User ${user.username} already exists in Keycloak`);
47
+        return checkUser.data[0].id;
48
+    }
49
+
50
+    await axios.post(
51
+        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users`,
52
+        {
53
+            username: user.username,
54
+            email: user.email,
55
+            firstName: user.firstname,
56
+            lastName: user.lastname,
57
+            enabled: true,
58
+            credentials: [
59
+                {
60
+                    type: 'password',
61
+                    value: user.password,
62
+                    temporary: false,
63
+                },
64
+            ],
65
+        },
66
+        {
67
+            headers: { Authorization: `Bearer ${token}` },
68
+        }
69
+    );
70
+
71
+    const { data } = await axios.get(
72
+        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users?username=${user.username}`,
73
+        {
74
+            headers: { Authorization: `Bearer ${token}` },
75
+        }
76
+    );
77
+
78
+    return data[0].id;
79
+};
80
+
81
+// Assign role ke user
82
+const assignRole = async (userId: string, roleName: string, token: string): Promise<void> => {
83
+    const { data: roles } = await axios.get(
84
+        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/roles`,
85
+        {
86
+            headers: { Authorization: `Bearer ${token}` },
87
+        }
88
+    );
89
+
90
+    const role = roles.find((r: any) => r.name === roleName);
91
+    if (!role) throw new Error(`Role "${roleName}" not found in Keycloak`);
92
+
93
+    await axios.post(
94
+        `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users/${userId}/role-mappings/realm`,
95
+        [role],
96
+        {
97
+            headers: { Authorization: `Bearer ${token}` },
98
+        }
99
+    );
100
+};
101
+
102
+// Data user yang ingin di-seed
103
+const users: SeedUser[] = [
104
+    {
105
+        username: 'admin1',
106
+        email: 'admin1@gmail.com',
107
+        password: 'password123',
108
+        firstname: 'Admin',
109
+        lastname: 'Satu',
110
+        role: 'admin',
111
+    },
112
+    {
113
+        username: 'sales1',
114
+        email: 'sales1@gmail.com',
115
+        password: 'password123',
116
+        firstname: 'Sales',
117
+        lastname: 'Satu',
118
+        role: 'sales',
119
+    },
120
+    {
121
+        username: 'sales2',
122
+        email: 'sales2@gmail.com',
123
+        password: 'password123',
124
+        firstname: 'Sales',
125
+        lastname: 'Dua',
126
+        role: 'sales',
127
+    },
128
+];
129
+
130
+// Fungsi utama untuk seeding user
131
+export const seedUsers = async (): Promise<void> => {
132
+    const token = await getAdminToken();
133
+
134
+    for (const user of users) {
135
+        const userId = await createUserInKeycloak(user, token);
136
+        await assignRole(userId, user.role, token);
137
+
138
+        const hashedPassword = await bcrypt.hash(user.password, 10);
139
+
140
+        await prisma.user.upsert({
141
+            where: { id: userId },
142
+            update: {},
143
+            create: {
144
+                id: userId,
145
+                username: user.username,
146
+                email: user.email,
147
+                firstname: user.firstname,
148
+                lastname: user.lastname,
149
+                password: hashedPassword,
150
+                role: user.role,
151
+            },
152
+        });
153
+
154
+        console.log(`✅ Success seed user ${user.role}: ${user.username}`);
155
+    }
156
+};
157
+
158
+
159
+// const axios = require('axios');
160
+// const qs = require('qs');
161
+// const bcrypt = require('bcrypt');
162
+// const prisma = require('../../src/prisma/PrismaClient.js');
163
+// const {
164
+//     KEYCLOAK_TOKEN_URL,
165
+//     KEYCLOAK_ADMIN_URL,
166
+//     KEYCLOAK_REALM,
167
+//     CLIENT_ID,
168
+//     CLIENT_SECRET,
169
+// } = require('../../config/keycloak.js');
170
+
171
+// // Ambil token admin Keycloak
172
+// const getAdminToken = async () => {
173
+//     const tokenParams = qs.stringify({
174
+//         grant_type: 'client_credentials',
175
+//         client_id: CLIENT_ID,
176
+//         client_secret: CLIENT_SECRET,
177
+//     });
178
+
179
+//     const { data } = await axios.post(KEYCLOAK_TOKEN_URL, tokenParams, {
180
+//         headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
181
+//     });
182
+
183
+//     return data.access_token;
184
+// };
185
+
186
+// // Buat user di Keycloak
187
+// const createUserInKeycloak = async (user, token) => {
188
+//     const checkUser = await axios.get(
189
+//         `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users?username=${user.username}`,
190
+//         { headers: { Authorization: `Bearer ${token}` } }
191
+//     );
192
+
193
+//     if (checkUser.data.length > 0) {
194
+//         console.log(`⚠️  User ${user.username} found in Keycloak`);
195
+//         return checkUser.data[0].id;
196
+//     }
197
+
198
+//     await axios.post(
199
+//         `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users`,
200
+//         {
201
+//             username: user.username,
202
+//             email: user.email,
203
+//             firstName: user.firstname,
204
+//             lastName: user.lastname,
205
+//             enabled: true,
206
+//             credentials: [
207
+//                 {
208
+//                     type: 'password',
209
+//                     value: user.password,
210
+//                     temporary: false,
211
+//                 },
212
+//             ],
213
+//         },
214
+//         {
215
+//             headers: { Authorization: `Bearer ${token}` },
216
+//         }
217
+//     );
218
+
219
+//     const { data } = await axios.get(
220
+//         `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users?username=${user.username}`,
221
+//         {
222
+//             headers: { Authorization: `Bearer ${token}` },
223
+//         }
224
+//     );
225
+
226
+//     return data[0].id;
227
+// };
228
+
229
+// // Assign role ke user di Keycloak
230
+// const assignRole = async (userId, roleName, token) => {
231
+//     const { data: roles } = await axios.get(
232
+//         `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/roles`,
233
+//         {
234
+//             headers: { Authorization: `Bearer ${token}` },
235
+//         }
236
+//     );
237
+
238
+//     const role = roles.find((r) => r.name === roleName);
239
+//     if (!role) throw new Error(`Role "${roleName}" not found in Keycloak`);
240
+
241
+//     await axios.post(
242
+//         `${KEYCLOAK_ADMIN_URL}/admin/realms/${KEYCLOAK_REALM}/users/${userId}/role-mappings/realm`,
243
+//         [role],
244
+//         {
245
+//             headers: { Authorization: `Bearer ${token}` },
246
+//         }
247
+//     );
248
+// };
249
+
250
+// // Data user yang ingin dibuat
251
+// const users = [
252
+//     {
253
+//         username: 'admin1',
254
+//         email: 'admin1@gmail.com',
255
+//         password: 'password123',
256
+//         firstname: 'Admin',
257
+//         lastname: 'Satu',
258
+//         role: 'admin',
259
+//     },
260
+//     {
261
+//         username: 'sales1',
262
+//         email: 'sales1@gmail.com',
263
+//         password: 'password123',
264
+//         firstname: 'Sales',
265
+//         lastname: 'Satu',
266
+//         role: 'sales',
267
+//     },
268
+//     {
269
+//         username: 'sales2',
270
+//         email: 'sales2@gmail.com',
271
+//         password: 'password123',
272
+//         firstname: 'Sales',
273
+//         lastname: 'Dua',
274
+//         role: 'sales',
275
+//     },
276
+// ];
277
+
278
+// // Fungsi utama yang bisa dipanggil dari seeder utama
279
+// const seedUsers = async () => {
280
+//     const token = await getAdminToken();
281
+
282
+//     for (const user of users) {
283
+//         const userId = await createUserInKeycloak(user, token);
284
+//         await assignRole(userId, user.role, token);
285
+
286
+//         const hashedPassword = await bcrypt.hash(user.password, 10);
287
+
288
+//         await prisma.user.upsert({
289
+//             where: { id: userId },
290
+//             update: {},
291
+//             create: {
292
+//                 id: userId,
293
+//                 username: user.username,
294
+//                 email: user.email,
295
+//                 firstname: user.firstname,
296
+//                 lastname: user.lastname,
297
+//                 password: hashedPassword,
298
+//                 role: user.role,
299
+//             },
300
+//         });
301
+
302
+//         console.log(`✅ Success seed user ${user.role}: ${user.username}`);
303
+//     }
304
+// };
305
+
306
+// module.exports = { seedUsers };

+ 0 - 69
prisma/seeders/VendorSeeder.js

@@ -1,69 +0,0 @@
1
-const prisma = require('../../src/prisma/PrismaClient.js');
2
-
3
-async function seedVendors() {
4
-    try {
5
-        // cari user role admin
6
-        const adminUser = await prisma.userKeycloak.findFirst({
7
-            where: {
8
-                id: 'ffc58d77-b098-4cc2-ad99-6eeeac8d87ab',
9
-            },
10
-        });
11
-
12
-        if (!adminUser) {
13
-            throw new Error('User with role admin not exists');
14
-        }
15
-
16
-        // Data vendor yang akan dimasukkan
17
-        const vendors = [
18
-            {
19
-                name: 'MediSoft SIMRS',
20
-                name_pt: 'PT Medisoft Technology',
21
-                strengths: 'Antarmuka user-friendly, support lengkap untuk modul RS',
22
-                weaknesses: 'Harga relatif tinggi',
23
-                website: 'https://medisoft.co.id',
24
-            },
25
-            {
26
-                name: 'SimRS Platinum',
27
-                name_pt: 'PT Platinum Healthtech',
28
-                strengths: 'Integrasi BPJS dan telemedicine',
29
-                weaknesses: 'Customisasi sulit',
30
-                website: 'https://simrsplatinum.id',
31
-            },
32
-            {
33
-                name: 'Hospicare System',
34
-                name_pt: 'PT Hospicare Nusantara',
35
-                strengths: 'Stabil dan dokumentasi lengkap',
36
-                weaknesses: 'Kurang inovatif',
37
-                website: 'https://hospicare.co.id',
38
-            },
39
-        ];
40
-
41
-        // Insert vendor dengan created_by dari adminUser.id
42
-        for (const vendor of vendors) {
43
-            await prisma.vendor.create({
44
-                data: {
45
-                    ...vendor,
46
-                    created_by: adminUser.id,
47
-                },
48
-            });
49
-        }
50
-
51
-        console.log('✅ Vendor seeded!');
52
-    } catch (error) {
53
-        console.error('❌ Error seeding vendor:', error);
54
-    }
55
-}
56
-
57
-module.exports = { seedVendors };
58
-
59
-if (require.main === module) {
60
-    seedVendors()
61
-        .then(() => {
62
-            console.log('🌱 Seeder selesai!');
63
-            process.exit(0);
64
-        })
65
-        .catch((err) => {
66
-            console.error('❌ Error saat seeding:', err);
67
-            process.exit(1);
68
-        });
69
-}

+ 123 - 0
prisma/seeders/VendorSeeder.ts

@@ -0,0 +1,123 @@
1
+import prisma from '../../src/prisma/PrismaClient';
2
+
3
+interface VendorInput {
4
+    name: string;
5
+    name_pt: string;
6
+    strengths: string;
7
+    weaknesses: string;
8
+    website: string;
9
+}
10
+
11
+export async function seedVendors(): Promise<void> {
12
+    try {
13
+        // Cari user dengan username admin1
14
+        const adminUser = await prisma.userKeycloak.findFirst({
15
+            where: {
16
+                id: 'd3dcbbbd-fc92-45cf-9520-d0a6859358f6',
17
+            },
18
+        });
19
+
20
+        if (!adminUser) {
21
+            throw new Error('User with username admin1 not found');
22
+        }
23
+
24
+        // Daftar vendor
25
+        const vendors: VendorInput[] = [
26
+            {
27
+                name: 'MediSoft SIMRS',
28
+                name_pt: 'PT Medisoft Technology',
29
+                strengths: 'Antarmuka user-friendly, support lengkap untuk modul RS',
30
+                weaknesses: 'Harga relatif tinggi',
31
+                website: 'https://medisoft.co.id',
32
+            },
33
+            {
34
+                name: 'SimRS Platinum',
35
+                name_pt: 'PT Platinum Healthtech',
36
+                strengths: 'Integrasi BPJS dan telemedicine',
37
+                weaknesses: 'Customisasi sulit',
38
+                website: 'https://simrsplatinum.id',
39
+            },
40
+            {
41
+                name: 'Hospicare System',
42
+                name_pt: 'PT Hospicare Nusantara',
43
+                strengths: 'Stabil dan dokumentasi lengkap',
44
+                weaknesses: 'Kurang inovatif',
45
+                website: 'https://hospicare.co.id',
46
+            },
47
+        ];
48
+
49
+        // Insert ke database
50
+        for (const vendor of vendors) {
51
+            await prisma.vendor.create({
52
+                data: {
53
+                    ...vendor,
54
+                    created_by: adminUser.id,
55
+                },
56
+            });
57
+        }
58
+
59
+        console.log('✅ Vendor seeded!');
60
+    } catch (error: any) {
61
+        console.error('❌ Error seeding vendor:', error.message);
62
+    }
63
+}
64
+
65
+seedVendors();
66
+
67
+// const prisma = require('../../src/prisma/PrismaClient.js');
68
+
69
+// async function seedVendors() {
70
+//     try {
71
+//         // cari user role admin
72
+//         const adminUser = await prisma.user.findFirst({
73
+//             where: {
74
+//                 username: 'admin1',
75
+//             },
76
+//         });
77
+
78
+//         if (!adminUser) {
79
+//             throw new Error('User with role admin not exists');
80
+//         }
81
+
82
+//         // Data vendor yang akan dimasukkan
83
+//         const vendors = [
84
+//             {
85
+//                 name: 'MediSoft SIMRS',
86
+//                 name_pt: 'PT Medisoft Technology',
87
+//                 strengths: 'Antarmuka user-friendly, support lengkap untuk modul RS',
88
+//                 weaknesses: 'Harga relatif tinggi',
89
+//                 website: 'https://medisoft.co.id',
90
+//             },
91
+//             {
92
+//                 name: 'SimRS Platinum',
93
+//                 name_pt: 'PT Platinum Healthtech',
94
+//                 strengths: 'Integrasi BPJS dan telemedicine',
95
+//                 weaknesses: 'Customisasi sulit',
96
+//                 website: 'https://simrsplatinum.id',
97
+//             },
98
+//             {
99
+//                 name: 'Hospicare System',
100
+//                 name_pt: 'PT Hospicare Nusantara',
101
+//                 strengths: 'Stabil dan dokumentasi lengkap',
102
+//                 weaknesses: 'Kurang inovatif',
103
+//                 website: 'https://hospicare.co.id',
104
+//             },
105
+//         ];
106
+
107
+//         // Insert vendor dengan created_by dari adminUser.id
108
+//         for (const vendor of vendors) {
109
+//             await prisma.vendor.create({
110
+//                 data: {
111
+//                     ...vendor,
112
+//                     created_by: adminUser.id,
113
+//                 },
114
+//             });
115
+//         }
116
+
117
+//         console.log('✅ Vendor seeded!');
118
+//     } catch (error) {
119
+//         console.error('❌ Error seeding vendor:', error);
120
+//     }
121
+// }
122
+
123
+// module.exports = { seedVendors };

+ 0 - 62
prisma/seeders/city/AcehCitySeeder.js

@@ -1,62 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Aceh Barat',
6
-    'Kabupaten Aceh Barat Daya',
7
-    'Kabupaten Aceh Besar',
8
-    'Kabupaten Aceh Jaya',
9
-    'Kabupaten Aceh Selatan',
10
-    'Kabupaten Aceh Singkil',
11
-    'Kabupaten Aceh Tamiang',
12
-    'Kabupaten Aceh Tengah',
13
-    'Kabupaten Aceh Tenggara',
14
-    'Kabupaten Aceh Timur',
15
-    'Kabupaten Aceh Utara',
16
-    'Kabupaten Bener Meriah',
17
-    'Kabupaten Bireuen',
18
-    'Kabupaten Gayo Lues',
19
-    'Kabupaten Nagan Raya',
20
-    'Kabupaten Pidie',
21
-    'Kabupaten Pidie Jaya',
22
-    'Kabupaten Simeulue',
23
-    'Kota Banda Aceh',
24
-    'Kota Langsa',
25
-    'Kota Lhokseumawe',
26
-    'Kota Sabang',
27
-    'Kota Subulussalam'
28
-
29
-    // 23
30
-];
31
-
32
-exports.seedAcehCities = async () => {
33
-    const province = await prisma.province.findFirst({
34
-        where: { name: 'Aceh' },
35
-    });
36
-
37
-    if (!province) {
38
-        console.error('❌ Province Aceh not found. Seed it first.');
39
-        return;
40
-    }
41
-
42
-    for (const name of cityNames) {
43
-        await prisma.city.upsert({
44
-            where: {
45
-                name_province_id: {
46
-                    name,
47
-                    province_id: province.id,
48
-                },
49
-            },
50
-            create: {
51
-                name,
52
-                province_id: province.id,
53
-                updatedAt: timeLocal.now().toDate()
54
-            },
55
-            update: {
56
-                updatedAt: timeLocal.now().toDate()
57
-            }
58
-        });
59
-    }
60
-
61
-    console.log('✅ Aceh City seeded!.');
62
-};

+ 124 - 0
prisma/seeders/city/AcehCitySeeder.ts

@@ -0,0 +1,124 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Aceh Barat',
6
+    'Kabupaten Aceh Barat Daya',
7
+    'Kabupaten Aceh Besar',
8
+    'Kabupaten Aceh Jaya',
9
+    'Kabupaten Aceh Selatan',
10
+    'Kabupaten Aceh Singkil',
11
+    'Kabupaten Aceh Tamiang',
12
+    'Kabupaten Aceh Tengah',
13
+    'Kabupaten Aceh Tenggara',
14
+    'Kabupaten Aceh Timur',
15
+    'Kabupaten Aceh Utara',
16
+    'Kabupaten Bener Meriah',
17
+    'Kabupaten Bireuen',
18
+    'Kabupaten Gayo Lues',
19
+    'Kabupaten Nagan Raya',
20
+    'Kabupaten Pidie',
21
+    'Kabupaten Pidie Jaya',
22
+    'Kabupaten Simeulue',
23
+    'Kota Banda Aceh',
24
+    'Kota Langsa',
25
+    'Kota Lhokseumawe',
26
+    'Kota Sabang',
27
+    'Kota Subulussalam'
28
+];
29
+
30
+export async function seedAcehCities(): Promise<void> {
31
+    const province = await prisma.province.findFirst({
32
+        where: { name: 'Aceh' },
33
+    });
34
+
35
+    if (!province) {
36
+        console.error('❌ Province Aceh not found. Seed it first.');
37
+        return;
38
+    }
39
+
40
+    for (const name of cityNames) {
41
+        await prisma.city.upsert({
42
+            where: {
43
+                name_province_id: {
44
+                    name,
45
+                    province_id: province.id,
46
+                },
47
+            },
48
+            create: {
49
+                name,
50
+                province_id: province.id,
51
+                updatedAt: now().toDate(),
52
+            },
53
+            update: {
54
+                updatedAt: now().toDate(),
55
+            },
56
+        });
57
+    }
58
+
59
+    console.log('✅ Aceh City seeded!');
60
+}
61
+
62
+
63
+// const prisma = require('../../../src/prisma/PrismaClient.js');
64
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
65
+
66
+// const cityNames = [
67
+//     'Kabupaten Aceh Barat',
68
+//     'Kabupaten Aceh Barat Daya',
69
+//     'Kabupaten Aceh Besar',
70
+//     'Kabupaten Aceh Jaya',
71
+//     'Kabupaten Aceh Selatan',
72
+//     'Kabupaten Aceh Singkil',
73
+//     'Kabupaten Aceh Tamiang',
74
+//     'Kabupaten Aceh Tengah',
75
+//     'Kabupaten Aceh Tenggara',
76
+//     'Kabupaten Aceh Timur',
77
+//     'Kabupaten Aceh Utara',
78
+//     'Kabupaten Bener Meriah',
79
+//     'Kabupaten Bireuen',
80
+//     'Kabupaten Gayo Lues',
81
+//     'Kabupaten Nagan Raya',
82
+//     'Kabupaten Pidie',
83
+//     'Kabupaten Pidie Jaya',
84
+//     'Kabupaten Simeulue',
85
+//     'Kota Banda Aceh',
86
+//     'Kota Langsa',
87
+//     'Kota Lhokseumawe',
88
+//     'Kota Sabang',
89
+//     'Kota Subulussalam'
90
+
91
+//     // 23
92
+// ];
93
+
94
+// exports.seedAcehCities = async () => {
95
+//     const province = await prisma.province.findFirst({
96
+//         where: { name: 'Aceh' },
97
+//     });
98
+
99
+//     if (!province) {
100
+//         console.error('❌ Province Aceh not found. Seed it first.');
101
+//         return;
102
+//     }
103
+
104
+//     for (const name of cityNames) {
105
+//         await prisma.city.upsert({
106
+//             where: {
107
+//                 name_province_id: {
108
+//                     name,
109
+//                     province_id: province.id,
110
+//                 },
111
+//             },
112
+//             create: {
113
+//                 name,
114
+//                 province_id: province.id,
115
+//                 updatedAt: timeLocal.now().toDate()
116
+//             },
117
+//             update: {
118
+//                 updatedAt: timeLocal.now().toDate()
119
+//             }
120
+//         });
121
+//     }
122
+
123
+//     console.log('✅ Aceh City seeded!.');
124
+// };

+ 0 - 48
prisma/seeders/city/BaliCitySeeder.js

@@ -1,48 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Badung',
6
-    'Kabupaten Bangli',
7
-    'Kabupaten Buleleng',
8
-    'Kabupaten Gianyar',
9
-    'Kabupaten Jembrana',
10
-    'Kabupaten Karangasem',
11
-    'Kabupaten Klungkung',
12
-    'Kabupaten Tabanan',
13
-    'Kota Denpasar'
14
-
15
-    // 9
16
-];
17
-
18
-exports.seedBaliCities = async () => {
19
-    const province = await prisma.province.findFirst({
20
-        where: { name: 'Bali' },
21
-    });
22
-
23
-    if (!province) {
24
-        console.error('❌ Province Bali not found. Seed it first.');
25
-        return;
26
-    }
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
-
47
-    console.log('✅ Bali City seeded!.');
48
-};

+ 96 - 0
prisma/seeders/city/BaliCitySeeder.ts

@@ -0,0 +1,96 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Badung',
6
+    'Kabupaten Bangli',
7
+    'Kabupaten Buleleng',
8
+    'Kabupaten Gianyar',
9
+    'Kabupaten Jembrana',
10
+    'Kabupaten Karangasem',
11
+    'Kabupaten Klungkung',
12
+    'Kabupaten Tabanan',
13
+    'Kota Denpasar'
14
+];
15
+
16
+export async function seedBaliCities(): Promise<void> {
17
+    const province = await prisma.province.findFirst({
18
+        where: { name: 'Bali' },
19
+    });
20
+
21
+    if (!province) {
22
+        console.error('❌ Province Bali not found. Seed it first.');
23
+        return;
24
+    }
25
+
26
+    for (const name of cityNames) {
27
+        await prisma.city.upsert({
28
+            where: {
29
+                name_province_id: {
30
+                    name,
31
+                    province_id: province.id,
32
+                },
33
+            },
34
+            update: {
35
+                updatedAt: now().toDate(),
36
+            },
37
+            create: {
38
+                name,
39
+                province_id: province.id,
40
+                createdAt: now().toDate(),
41
+            },
42
+        });
43
+    }
44
+
45
+    console.log('✅ Bali City seeded!');
46
+}
47
+
48
+
49
+// const prisma = require('../../../src/prisma/PrismaClient.js');
50
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
51
+
52
+// const cityNames = [
53
+//     'Kabupaten Badung',
54
+//     'Kabupaten Bangli',
55
+//     'Kabupaten Buleleng',
56
+//     'Kabupaten Gianyar',
57
+//     'Kabupaten Jembrana',
58
+//     'Kabupaten Karangasem',
59
+//     'Kabupaten Klungkung',
60
+//     'Kabupaten Tabanan',
61
+//     'Kota Denpasar'
62
+
63
+//     // 9
64
+// ];
65
+
66
+// exports.seedBaliCities = async () => {
67
+//     const province = await prisma.province.findFirst({
68
+//         where: { name: 'Bali' },
69
+//     });
70
+
71
+//     if (!province) {
72
+//         console.error('❌ Province Bali not found. Seed it first.');
73
+//         return;
74
+//     }
75
+
76
+//     for (const name of cityNames) {
77
+//         await prisma.city.upsert({
78
+//             where: {
79
+//                 name_province_id: {
80
+//                     name,
81
+//                     province_id: province.id,
82
+//                 },
83
+//             },
84
+//             update: {
85
+//                 updatedAt: timeLocal.now().toDate()
86
+//             },
87
+//             create: {
88
+//                 name,
89
+//                 province_id: province.id,
90
+//                 createdAt: timeLocal.now().toDate()
91
+//             },
92
+//         });
93
+//     }
94
+
95
+//     console.log('✅ Bali City seeded!.');
96
+// };

+ 0 - 47
prisma/seeders/city/BantenCitySeeder.js

@@ -1,47 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Lebak',
6
-    'Kabupaten Pandeglang',
7
-    'Kabupaten Serang',
8
-    'Kabupaten Tangerang',
9
-    'Kota Cilegon',
10
-    'Kota Serang',
11
-    'Kota Tangerang',
12
-    'Kota Tangerang Selatan'
13
-
14
-    // 8
15
-];
16
-
17
-exports.seedBantenCities = async () => {
18
-    const province = await prisma.province.findFirst({
19
-        where: { name: 'Banten' },
20
-    });
21
-
22
-    if (!province) {
23
-        console.error('❌ Province Banten not found. Seed it first.');
24
-        return;
25
-    }
26
-
27
-    for (const name of cityNames) {
28
-        await prisma.city.upsert({
29
-            where: {
30
-                name_province_id: {
31
-                    name,
32
-                    province_id: province.id,
33
-                },
34
-            },
35
-            update: {
36
-                updatedAt: timeLocal.now().toDate()
37
-            },
38
-            create: {
39
-                name,
40
-                province_id: province.id,
41
-                createdAt: timeLocal.now().toDate()
42
-            },
43
-        });
44
-    }
45
-
46
-    console.log('✅ Banten City seeded!.');
47
-};

+ 93 - 0
prisma/seeders/city/BantenCitySeeder.ts

@@ -0,0 +1,93 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Lebak',
6
+    'Kabupaten Pandeglang',
7
+    'Kabupaten Serang',
8
+    'Kabupaten Tangerang',
9
+    'Kota Cilegon',
10
+    'Kota Serang',
11
+    'Kota Tangerang',
12
+    'Kota Tangerang Selatan'
13
+];
14
+
15
+export async function seedBantenCities(): Promise<void> {
16
+    const province = await prisma.province.findFirst({
17
+        where: { name: 'Banten' },
18
+    });
19
+
20
+    if (!province) {
21
+        console.error('❌ Province Banten not found. Seed it first.');
22
+        return;
23
+    }
24
+
25
+    for (const name of cityNames) {
26
+        await prisma.city.upsert({
27
+            where: {
28
+                name_province_id: {
29
+                    name,
30
+                    province_id: province.id,
31
+                },
32
+            },
33
+            update: {
34
+                updatedAt: now().toDate(),
35
+            },
36
+            create: {
37
+                name,
38
+                province_id: province.id,
39
+                createdAt: now().toDate(),
40
+            },
41
+        });
42
+    }
43
+
44
+    console.log('✅ Banten City seeded!');
45
+}
46
+
47
+// const prisma = require('../../../src/prisma/PrismaClient.js');
48
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
49
+
50
+// const cityNames = [
51
+//     'Kabupaten Lebak',
52
+//     'Kabupaten Pandeglang',
53
+//     'Kabupaten Serang',
54
+//     'Kabupaten Tangerang',
55
+//     'Kota Cilegon',
56
+//     'Kota Serang',
57
+//     'Kota Tangerang',
58
+//     'Kota Tangerang Selatan'
59
+
60
+//     // 8
61
+// ];
62
+
63
+// exports.seedBantenCities = async () => {
64
+//     const province = await prisma.province.findFirst({
65
+//         where: { name: 'Banten' },
66
+//     });
67
+
68
+//     if (!province) {
69
+//         console.error('❌ Province Banten not found. Seed it first.');
70
+//         return;
71
+//     }
72
+
73
+//     for (const name of cityNames) {
74
+//         await prisma.city.upsert({
75
+//             where: {
76
+//                 name_province_id: {
77
+//                     name,
78
+//                     province_id: province.id,
79
+//                 },
80
+//             },
81
+//             update: {
82
+//                 updatedAt: timeLocal.now().toDate()
83
+//             },
84
+//             create: {
85
+//                 name,
86
+//                 province_id: province.id,
87
+//                 createdAt: timeLocal.now().toDate()
88
+//             },
89
+//         });
90
+//     }
91
+
92
+//     console.log('✅ Banten City seeded!.');
93
+// };

+ 0 - 47
prisma/seeders/city/BengkuluCitySeeder.js

@@ -1,47 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bengkulu Selatan',
6
-    'Kabupaten Bengkulu Tengah',
7
-    'Kabupaten Bengkulu Utara',
8
-    'Kabupaten Kaur',
9
-    'Kabupaten Kepahiang',
10
-    'Kabupaten Lebong',
11
-    'Kabupaten Muko Muko',
12
-    'Kabupaten Rejang Lebong',
13
-    'Kabupaten Seluma',
14
-    'Kota Bengkulu'
15
-
16
-    // 10
17
-];
18
-
19
-exports.seedBengkuluCities = async () => {
20
-    const province = await prisma.province.findFirst({
21
-        where: { name: 'Bengkulu' },
22
-    });
23
-
24
-    if (!province) {
25
-        console.error('❌ Province Bengkulu not found. Seed it first.');
26
-        return;
27
-    }
28
-
29
-    for (const name of cityNames) {
30
-        await prisma.city.upsert({
31
-            where: {
32
-                name_province_id: {
33
-                    name,
34
-                    province_id: province.id,
35
-                },
36
-            },
37
-            update: { updatedAt: timeLocal.now().toDate() },
38
-            create: {
39
-                name,
40
-                province_id: province.id,
41
-                createdAt: timeLocal.now().toDate()
42
-            },
43
-        });
44
-    }
45
-
46
-    console.log('✅ Bengkulu City seeded!.');
47
-};

+ 96 - 0
prisma/seeders/city/BengkuluCitySeeder.ts

@@ -0,0 +1,96 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bengkulu Selatan',
6
+    'Kabupaten Bengkulu Tengah',
7
+    'Kabupaten Bengkulu Utara',
8
+    'Kabupaten Kaur',
9
+    'Kabupaten Kepahiang',
10
+    'Kabupaten Lebong',
11
+    'Kabupaten Muko Muko',
12
+    'Kabupaten Rejang Lebong',
13
+    'Kabupaten Seluma',
14
+    'Kota Bengkulu'
15
+];
16
+
17
+export async function seedBengkuluCities(): Promise<void> {
18
+    const province = await prisma.province.findFirst({
19
+        where: { name: 'Bengkulu' },
20
+    });
21
+
22
+    if (!province) {
23
+        console.error('❌ Province Bengkulu not found. Seed it first.');
24
+        return;
25
+    }
26
+
27
+    for (const name of cityNames) {
28
+        await prisma.city.upsert({
29
+            where: {
30
+                name_province_id: {
31
+                    name,
32
+                    province_id: province.id,
33
+                },
34
+            },
35
+            update: {
36
+                updatedAt: now().toDate(),
37
+            },
38
+            create: {
39
+                name,
40
+                province_id: province.id,
41
+                createdAt: now().toDate(),
42
+            },
43
+        });
44
+    }
45
+
46
+    console.log('✅ Bengkulu City seeded!');
47
+}
48
+
49
+
50
+// const prisma = require('../../../src/prisma/PrismaClient.js');
51
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
52
+
53
+// const cityNames = [
54
+//     'Kabupaten Bengkulu Selatan',
55
+//     'Kabupaten Bengkulu Tengah',
56
+//     'Kabupaten Bengkulu Utara',
57
+//     'Kabupaten Kaur',
58
+//     'Kabupaten Kepahiang',
59
+//     'Kabupaten Lebong',
60
+//     'Kabupaten Muko Muko',
61
+//     'Kabupaten Rejang Lebong',
62
+//     'Kabupaten Seluma',
63
+//     'Kota Bengkulu'
64
+
65
+//     // 10
66
+// ];
67
+
68
+// exports.seedBengkuluCities = async () => {
69
+//     const province = await prisma.province.findFirst({
70
+//         where: { name: 'Bengkulu' },
71
+//     });
72
+
73
+//     if (!province) {
74
+//         console.error('❌ Province Bengkulu not found. Seed it first.');
75
+//         return;
76
+//     }
77
+
78
+//     for (const name of cityNames) {
79
+//         await prisma.city.upsert({
80
+//             where: {
81
+//                 name_province_id: {
82
+//                     name,
83
+//                     province_id: province.id,
84
+//                 },
85
+//             },
86
+//             update: { updatedAt: timeLocal.now().toDate() },
87
+//             create: {
88
+//                 name,
89
+//                 province_id: province.id,
90
+//                 createdAt: timeLocal.now().toDate()
91
+//             },
92
+//         });
93
+//     }
94
+
95
+//     console.log('✅ Bengkulu City seeded!.');
96
+// };

+ 0 - 42
prisma/seeders/city/DIYogyakartaCitySeeder.js

@@ -1,42 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bantul',
6
-    'Kabupaten Gunungkidul',
7
-    'Kabupaten Kulon Progo',
8
-    'Kabupaten Sleman',
9
-    'Kota Yogyakarta'
10
-
11
-    // 5
12
-];
13
-
14
-exports.seedDIYogyakartaCities = async () => {
15
-    const province = await prisma.province.findFirst({
16
-        where: { name: 'DI Yogyakarta' },
17
-    });
18
-
19
-    if (!province) {
20
-        console.error('❌ Province DI Yogyakarta not found. Seed it first.');
21
-        return;
22
-    }
23
-
24
-    for (const name of cityNames) {
25
-        await prisma.city.upsert({
26
-            where: {
27
-                name_province_id: {
28
-                    name,
29
-                    province_id: province.id,
30
-                },
31
-            },
32
-            update: { updatedAt: timeLocal.now().toDate() },
33
-            create: {
34
-                name,
35
-                province_id: province.id,
36
-                createdAt: timeLocal.now().toDate()
37
-            },
38
-        });
39
-    }
40
-
41
-    console.log('✅ DI Yogyakarta City seeded!.');
42
-};

+ 83 - 0
prisma/seeders/city/DIYogyakartaCitySeeder.ts

@@ -0,0 +1,83 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bantul',
6
+    'Kabupaten Gunungkidul',
7
+    'Kabupaten Kulon Progo',
8
+    'Kabupaten Sleman',
9
+    'Kota Yogyakarta'
10
+];
11
+
12
+export async function seedDIYogyakartaCities(): Promise<void> {
13
+    const province = await prisma.province.findFirst({
14
+        where: { name: 'DI Yogyakarta' },
15
+    });
16
+
17
+    if (!province) {
18
+        console.error('❌ Province DI Yogyakarta not found. Seed it first.');
19
+        return;
20
+    }
21
+
22
+    for (const name of cityNames) {
23
+        await prisma.city.upsert({
24
+            where: {
25
+                name_province_id: {
26
+                    name,
27
+                    province_id: province.id,
28
+                },
29
+            },
30
+            update: { updatedAt: now().toDate() },
31
+            create: {
32
+                name,
33
+                province_id: province.id,
34
+                createdAt: now().toDate(),
35
+            },
36
+        });
37
+    }
38
+
39
+    console.log('✅ DI Yogyakarta City seeded!');
40
+}
41
+
42
+// const prisma = require('../../../src/prisma/PrismaClient.js');
43
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
44
+
45
+// const cityNames = [
46
+//     'Kabupaten Bantul',
47
+//     'Kabupaten Gunungkidul',
48
+//     'Kabupaten Kulon Progo',
49
+//     'Kabupaten Sleman',
50
+//     'Kota Yogyakarta'
51
+
52
+//     // 5
53
+// ];
54
+
55
+// exports.seedDIYogyakartaCities = async () => {
56
+//     const province = await prisma.province.findFirst({
57
+//         where: { name: 'DI Yogyakarta' },
58
+//     });
59
+
60
+//     if (!province) {
61
+//         console.error('❌ Province DI Yogyakarta not found. Seed it first.');
62
+//         return;
63
+//     }
64
+
65
+//     for (const name of cityNames) {
66
+//         await prisma.city.upsert({
67
+//             where: {
68
+//                 name_province_id: {
69
+//                     name,
70
+//                     province_id: province.id,
71
+//                 },
72
+//             },
73
+//             update: { updatedAt: timeLocal.now().toDate() },
74
+//             create: {
75
+//                 name,
76
+//                 province_id: province.id,
77
+//                 createdAt: timeLocal.now().toDate()
78
+//             },
79
+//         });
80
+//     }
81
+
82
+//     console.log('✅ DI Yogyakarta City seeded!.');
83
+// };

+ 0 - 45
prisma/seeders/city/DKIJakartaCitySeeder.js

@@ -1,45 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Kepulauan Seribu',
6
-    'Kota Jakarta Barat',
7
-    'Kota Jakarta Pusat',
8
-    'Kota Jakarta Selatan',
9
-    'Kota Jakarta Timur',
10
-    'Kota Jakarta Utara'
11
-
12
-    // 6
13
-];
14
-
15
-exports.seedDKIJakartaCities = async () => {
16
-    const province = await prisma.province.findFirst({
17
-        where: { name: 'DKI Jakarta' },
18
-    });
19
-
20
-    if (!province) {
21
-        console.error('❌ Province DKI Jakarta not found. Seed it first.');
22
-        return;
23
-    }
24
-
25
-    for (const name of cityNames) {
26
-        await prisma.city.upsert({
27
-            where: {
28
-                name_province_id: {
29
-                    name,
30
-                    province_id: province.id,
31
-                },
32
-            },
33
-            update: {
34
-                updatedAt: timeLocal.now().toDate()
35
-            },
36
-            create: {
37
-                name,
38
-                province_id: province.id,
39
-                createdAt: timeLocal.now().toDate()
40
-            },
41
-        });
42
-    }
43
-
44
-    console.log('✅ DKI Jakarta City seeded!.');
45
-};

+ 90 - 0
prisma/seeders/city/DKIJakartaCitySeeder.ts

@@ -0,0 +1,90 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Kepulauan Seribu',
6
+    'Kota Jakarta Barat',
7
+    'Kota Jakarta Pusat',
8
+    'Kota Jakarta Selatan',
9
+    'Kota Jakarta Timur',
10
+    'Kota Jakarta Utara'
11
+];
12
+
13
+export async function seedDKIJakartaCities(): Promise<void> {
14
+    const province = await prisma.province.findFirst({
15
+        where: { name: 'DKI Jakarta' },
16
+    });
17
+
18
+    if (!province) {
19
+        console.error('❌ Province DKI Jakarta not found. Seed it first.');
20
+        return;
21
+    }
22
+
23
+    for (const name of cityNames) {
24
+        await prisma.city.upsert({
25
+            where: {
26
+                name_province_id: {
27
+                    name,
28
+                    province_id: province.id,
29
+                },
30
+            },
31
+            update: {
32
+                updatedAt: now().toDate(),
33
+            },
34
+            create: {
35
+                name,
36
+                province_id: province.id,
37
+                createdAt: now().toDate(),
38
+            },
39
+        });
40
+    }
41
+
42
+    console.log('✅ DKI Jakarta City seeded!');
43
+}
44
+
45
+
46
+// const prisma = require('../../../src/prisma/PrismaClient.js');
47
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
48
+
49
+// const cityNames = [
50
+//     'Kabupaten Kepulauan Seribu',
51
+//     'Kota Jakarta Barat',
52
+//     'Kota Jakarta Pusat',
53
+//     'Kota Jakarta Selatan',
54
+//     'Kota Jakarta Timur',
55
+//     'Kota Jakarta Utara'
56
+
57
+//     // 6
58
+// ];
59
+
60
+// exports.seedDKIJakartaCities = async () => {
61
+//     const province = await prisma.province.findFirst({
62
+//         where: { name: 'DKI Jakarta' },
63
+//     });
64
+
65
+//     if (!province) {
66
+//         console.error('❌ Province DKI Jakarta not found. Seed it first.');
67
+//         return;
68
+//     }
69
+
70
+//     for (const name of cityNames) {
71
+//         await prisma.city.upsert({
72
+//             where: {
73
+//                 name_province_id: {
74
+//                     name,
75
+//                     province_id: province.id,
76
+//                 },
77
+//             },
78
+//             update: {
79
+//                 updatedAt: timeLocal.now().toDate()
80
+//             },
81
+//             create: {
82
+//                 name,
83
+//                 province_id: province.id,
84
+//                 createdAt: timeLocal.now().toDate()
85
+//             },
86
+//         });
87
+//     }
88
+
89
+//     console.log('✅ DKI Jakarta City seeded!.');
90
+// };

+ 0 - 45
prisma/seeders/city/GorontaloCitySeeder.js

@@ -1,45 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Boalemo',
6
-    'Kabupaten Bone Bolango',
7
-    'Kabupaten Gorontalo',
8
-    'Kabupaten Gorontalo Utara',
9
-    'Kabupaten Pohuwato',
10
-    'Kota Gorontalo'
11
-
12
-    // 6
13
-];
14
-
15
-exports.seedGorontaloCities = async () => {
16
-    const province = await prisma.province.findFirst({
17
-        where: { name: 'Gorontalo' },
18
-    });
19
-
20
-    if (!province) {
21
-        console.error('❌ Province Gorontalo not found. Seed it first.');
22
-        return;
23
-    }
24
-
25
-    for (const name of cityNames) {
26
-        await prisma.city.upsert({
27
-            where: {
28
-                name_province_id: {
29
-                    name,
30
-                    province_id: province.id,
31
-                },
32
-            },
33
-            update: {
34
-                updatedAt: timeLocal.now().toDate()
35
-            },
36
-            create: {
37
-                name,
38
-                province_id: province.id,
39
-                createdAt: timeLocal.now().toDate()
40
-            },
41
-        });
42
-    }
43
-
44
-    console.log('✅ Gorontalo City seeded!.');
45
-};

+ 89 - 0
prisma/seeders/city/GorontaloCitySeeder.ts

@@ -0,0 +1,89 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Boalemo',
6
+    'Kabupaten Bone Bolango',
7
+    'Kabupaten Gorontalo',
8
+    'Kabupaten Gorontalo Utara',
9
+    'Kabupaten Pohuwato',
10
+    'Kota Gorontalo'
11
+];
12
+
13
+export async function seedGorontaloCities(): Promise<void> {
14
+    const province = await prisma.province.findFirst({
15
+        where: { name: 'Gorontalo' },
16
+    });
17
+
18
+    if (!province) {
19
+        console.error('❌ Province Gorontalo not found. Seed it first.');
20
+        return;
21
+    }
22
+
23
+    for (const name of cityNames) {
24
+        await prisma.city.upsert({
25
+            where: {
26
+                name_province_id: {
27
+                    name,
28
+                    province_id: province.id,
29
+                },
30
+            },
31
+            update: {
32
+                updatedAt: now().toDate(),
33
+            },
34
+            create: {
35
+                name,
36
+                province_id: province.id,
37
+                createdAt: now().toDate(),
38
+            },
39
+        });
40
+    }
41
+
42
+    console.log('✅ Gorontalo City seeded!');
43
+}
44
+
45
+// const prisma = require('../../../src/prisma/PrismaClient.js');
46
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
47
+
48
+// const cityNames = [
49
+//     'Kabupaten Boalemo',
50
+//     'Kabupaten Bone Bolango',
51
+//     'Kabupaten Gorontalo',
52
+//     'Kabupaten Gorontalo Utara',
53
+//     'Kabupaten Pohuwato',
54
+//     'Kota Gorontalo'
55
+
56
+//     // 6
57
+// ];
58
+
59
+// exports.seedGorontaloCities = async () => {
60
+//     const province = await prisma.province.findFirst({
61
+//         where: { name: 'Gorontalo' },
62
+//     });
63
+
64
+//     if (!province) {
65
+//         console.error('❌ Province Gorontalo not found. Seed it first.');
66
+//         return;
67
+//     }
68
+
69
+//     for (const name of cityNames) {
70
+//         await prisma.city.upsert({
71
+//             where: {
72
+//                 name_province_id: {
73
+//                     name,
74
+//                     province_id: province.id,
75
+//                 },
76
+//             },
77
+//             update: {
78
+//                 updatedAt: timeLocal.now().toDate()
79
+//             },
80
+//             create: {
81
+//                 name,
82
+//                 province_id: province.id,
83
+//                 createdAt: timeLocal.now().toDate()
84
+//             },
85
+//         });
86
+//     }
87
+
88
+//     console.log('✅ Gorontalo City seeded!.');
89
+// };

+ 0 - 50
prisma/seeders/city/JambiCitySeeder.js

@@ -1,50 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Batang Hari',
6
-    'Kabupaten Bungo',
7
-    'Kabupaten Kerinci',
8
-    'Kabupaten Merangin',
9
-    'Kabupaten Muaro Jambi',
10
-    'Kabupaten Sarolangun',
11
-    'Kabupaten Tanjung Jabung Barat',
12
-    'Kabupaten Tanjung Jabung Timur',
13
-    'Kabupaten Tebo',
14
-    'Kota Jambi',
15
-    'Kota Sungai Penuh'
16
-
17
-    // 11
18
-];
19
-
20
-exports.seedJambiCities = async () => {
21
-    const province = await prisma.province.findFirst({
22
-        where: { name: 'Jambi' },
23
-    });
24
-
25
-    if (!province) {
26
-        console.error('❌ Province Jambi not found. Seed it first.');
27
-        return;
28
-    }
29
-
30
-    for (const name of cityNames) {
31
-        await prisma.city.upsert({
32
-            where: {
33
-                name_province_id: {
34
-                    name,
35
-                    province_id: province.id,
36
-                },
37
-            },
38
-            update: {
39
-                updatedAt: timeLocal.now().toDate()
40
-            },
41
-            create: {
42
-                name,
43
-                province_id: province.id,
44
-                createdAt: timeLocal.now().toDate()
45
-            },
46
-        });
47
-    }
48
-
49
-    console.log('✅ Jambi City seeded!.');
50
-};

+ 100 - 0
prisma/seeders/city/JambiCitySeeder.ts

@@ -0,0 +1,100 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Batang Hari',
6
+    'Kabupaten Bungo',
7
+    'Kabupaten Kerinci',
8
+    'Kabupaten Merangin',
9
+    'Kabupaten Muaro Jambi',
10
+    'Kabupaten Sarolangun',
11
+    'Kabupaten Tanjung Jabung Barat',
12
+    'Kabupaten Tanjung Jabung Timur',
13
+    'Kabupaten Tebo',
14
+    'Kota Jambi',
15
+    'Kota Sungai Penuh'
16
+];
17
+
18
+export async function seedJambiCities(): Promise<void> {
19
+    const province = await prisma.province.findFirst({
20
+        where: { name: 'Jambi' },
21
+    });
22
+
23
+    if (!province) {
24
+        console.error('❌ Province Jambi not found. Seed it first.');
25
+        return;
26
+    }
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: now().toDate(),
38
+            },
39
+            create: {
40
+                name,
41
+                province_id: province.id,
42
+                createdAt: now().toDate(),
43
+            },
44
+        });
45
+    }
46
+
47
+    console.log('✅ Jambi City seeded!');
48
+}
49
+
50
+
51
+// const prisma = require('../../../src/prisma/PrismaClient.js');
52
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
53
+
54
+// const cityNames = [
55
+//     'Kabupaten Batang Hari',
56
+//     'Kabupaten Bungo',
57
+//     'Kabupaten Kerinci',
58
+//     'Kabupaten Merangin',
59
+//     'Kabupaten Muaro Jambi',
60
+//     'Kabupaten Sarolangun',
61
+//     'Kabupaten Tanjung Jabung Barat',
62
+//     'Kabupaten Tanjung Jabung Timur',
63
+//     'Kabupaten Tebo',
64
+//     'Kota Jambi',
65
+//     'Kota Sungai Penuh'
66
+
67
+//     // 11
68
+// ];
69
+
70
+// exports.seedJambiCities = async () => {
71
+//     const province = await prisma.province.findFirst({
72
+//         where: { name: 'Jambi' },
73
+//     });
74
+
75
+//     if (!province) {
76
+//         console.error('❌ Province Jambi not found. Seed it first.');
77
+//         return;
78
+//     }
79
+
80
+//     for (const name of cityNames) {
81
+//         await prisma.city.upsert({
82
+//             where: {
83
+//                 name_province_id: {
84
+//                     name,
85
+//                     province_id: province.id,
86
+//                 },
87
+//             },
88
+//             update: {
89
+//                 updatedAt: timeLocal.now().toDate()
90
+//             },
91
+//             create: {
92
+//                 name,
93
+//                 province_id: province.id,
94
+//                 createdAt: timeLocal.now().toDate()
95
+//             },
96
+//         });
97
+//     }
98
+
99
+//     console.log('✅ Jambi City seeded!.');
100
+// };

+ 0 - 66
prisma/seeders/city/JawaBaratCitySeeder.js

@@ -1,66 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bandung',
6
-    'Kabupaten Bandung Barat',
7
-    'Kabupaten Bekasi',
8
-    'Kabupaten Bogor',
9
-    'Kabupaten Ciamis',
10
-    'Kabupaten Cianjur',
11
-    'Kabupaten Cirebon',
12
-    'Kabupaten Garut',
13
-    'Kabupaten Indramayu',
14
-    'Kabupaten Karawang',
15
-    'Kabupaten Kuningan',
16
-    'Kabupaten Majalengka',
17
-    'Kabupaten Pangandaran',
18
-    'Kabupaten Purwakarta',
19
-    'Kabupaten Subang',
20
-    'Kabupaten Sukabumi',
21
-    'Kabupaten Sumedang',
22
-    'Kabupaten Tasikmalaya',
23
-    'Kota Bandung',
24
-    'Kota Banjar',
25
-    'Kota Bekasi',
26
-    'Kota Bogor',
27
-    'Kota Cimahi',
28
-    'Kota Cirebon',
29
-    'Kota Depok',
30
-    'Kota Sukabumi',
31
-    'Kota Tasikmalaya'
32
-
33
-    // 27
34
-];
35
-
36
-exports.seedJawaBaratCities = async () => {
37
-    const province = await prisma.province.findFirst({
38
-        where: { name: 'Jawa Barat' },
39
-    });
40
-
41
-    if (!province) {
42
-        console.error('❌ Province Jawa Barat not found. Seed it first.');
43
-        return;
44
-    }
45
-
46
-    for (const name of cityNames) {
47
-        await prisma.city.upsert({
48
-            where: {
49
-                name_province_id: {
50
-                    name,
51
-                    province_id: province.id,
52
-                },
53
-            },
54
-            update: {
55
-                updatedAt: timeLocal.now().toDate()
56
-            },
57
-            create: {
58
-                name,
59
-                province_id: province.id,
60
-                createdAt: timeLocal.now().toDate()
61
-            },
62
-        });
63
-    }
64
-
65
-    console.log('✅ Jawa Barat City seeded!.');
66
-};

+ 131 - 0
prisma/seeders/city/JawaBaratCitySeeder.ts

@@ -0,0 +1,131 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bandung',
6
+    'Kabupaten Bandung Barat',
7
+    'Kabupaten Bekasi',
8
+    'Kabupaten Bogor',
9
+    'Kabupaten Ciamis',
10
+    'Kabupaten Cianjur',
11
+    'Kabupaten Cirebon',
12
+    'Kabupaten Garut',
13
+    'Kabupaten Indramayu',
14
+    'Kabupaten Karawang',
15
+    'Kabupaten Kuningan',
16
+    'Kabupaten Majalengka',
17
+    'Kabupaten Pangandaran',
18
+    'Kabupaten Purwakarta',
19
+    'Kabupaten Subang',
20
+    'Kabupaten Sukabumi',
21
+    'Kabupaten Sumedang',
22
+    'Kabupaten Tasikmalaya',
23
+    'Kota Bandung',
24
+    'Kota Banjar',
25
+    'Kota Bekasi',
26
+    'Kota Bogor',
27
+    'Kota Cimahi',
28
+    'Kota Cirebon',
29
+    'Kota Depok',
30
+    'Kota Sukabumi',
31
+    'Kota Tasikmalaya'
32
+];
33
+
34
+export async function seedJawaBaratCities(): Promise<void> {
35
+    const province = await prisma.province.findFirst({
36
+        where: { name: 'Jawa Barat' },
37
+    });
38
+
39
+    if (!province) {
40
+        console.error('❌ Province Jawa Barat not found. Seed it first.');
41
+        return;
42
+    }
43
+
44
+    for (const name of cityNames) {
45
+        await prisma.city.upsert({
46
+            where: {
47
+                name_province_id: {
48
+                    name,
49
+                    province_id: province.id,
50
+                },
51
+            },
52
+            update: {
53
+                updatedAt: now().toDate(),
54
+            },
55
+            create: {
56
+                name,
57
+                province_id: province.id,
58
+                createdAt: now().toDate(),
59
+            },
60
+        });
61
+    }
62
+
63
+    console.log('✅ Jawa Barat City seeded!');
64
+}
65
+
66
+// const prisma = require('../../../src/prisma/PrismaClient.js');
67
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
68
+
69
+// const cityNames = [
70
+//     'Kabupaten Bandung',
71
+//     'Kabupaten Bandung Barat',
72
+//     'Kabupaten Bekasi',
73
+//     'Kabupaten Bogor',
74
+//     'Kabupaten Ciamis',
75
+//     'Kabupaten Cianjur',
76
+//     'Kabupaten Cirebon',
77
+//     'Kabupaten Garut',
78
+//     'Kabupaten Indramayu',
79
+//     'Kabupaten Karawang',
80
+//     'Kabupaten Kuningan',
81
+//     'Kabupaten Majalengka',
82
+//     'Kabupaten Pangandaran',
83
+//     'Kabupaten Purwakarta',
84
+//     'Kabupaten Subang',
85
+//     'Kabupaten Sukabumi',
86
+//     'Kabupaten Sumedang',
87
+//     'Kabupaten Tasikmalaya',
88
+//     'Kota Bandung',
89
+//     'Kota Banjar',
90
+//     'Kota Bekasi',
91
+//     'Kota Bogor',
92
+//     'Kota Cimahi',
93
+//     'Kota Cirebon',
94
+//     'Kota Depok',
95
+//     'Kota Sukabumi',
96
+//     'Kota Tasikmalaya'
97
+
98
+//     // 27
99
+// ];
100
+
101
+// exports.seedJawaBaratCities = async () => {
102
+//     const province = await prisma.province.findFirst({
103
+//         where: { name: 'Jawa Barat' },
104
+//     });
105
+
106
+//     if (!province) {
107
+//         console.error('❌ Province Jawa Barat not found. Seed it first.');
108
+//         return;
109
+//     }
110
+
111
+//     for (const name of cityNames) {
112
+//         await prisma.city.upsert({
113
+//             where: {
114
+//                 name_province_id: {
115
+//                     name,
116
+//                     province_id: province.id,
117
+//                 },
118
+//             },
119
+//             update: {
120
+//                 updatedAt: timeLocal.now().toDate()
121
+//             },
122
+//             create: {
123
+//                 name,
124
+//                 province_id: province.id,
125
+//                 createdAt: timeLocal.now().toDate()
126
+//             },
127
+//         });
128
+//     }
129
+
130
+//     console.log('✅ Jawa Barat City seeded!.');
131
+// };

+ 0 - 74
prisma/seeders/city/JawaTengahCitySeeder.js

@@ -1,74 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Banjarnegara',
6
-    'Kabupaten Banyumas',
7
-    'Kabupaten Batang',
8
-    'Kabupaten Blora',
9
-    'Kabupaten Boyolali',
10
-    'Kabupaten Brebes',
11
-    'Kabupaten Cilacap',
12
-    'Kabupaten Demak',
13
-    'Kabupaten Grobogan',
14
-    'Kabupaten Jepara',
15
-    'Kabupaten Karanganyar',
16
-    'Kabupaten Kebumen',
17
-    'Kabupaten Kendal',
18
-    'Kabupaten Klaten',
19
-    'Kabupaten Kudus',
20
-    'Kabupaten Magelang',
21
-    'Kabupaten Pati',
22
-    'Kabupaten Pekalongan',
23
-    'Kabupaten Pemalang',
24
-    'Kabupaten Purbalingga',
25
-    'Kabupaten Purworejo',
26
-    'Kabupaten Rembang',
27
-    'Kabupaten Semarang',
28
-    'Kabupaten Sragen',
29
-    'Kabupaten Sukoharjo',
30
-    'Kabupaten Tegal',
31
-    'Kabupaten Temanggung',
32
-    'Kabupaten Wonogiri',
33
-    'Kabupaten Wonosobo',
34
-    'Kota Magelang',
35
-    'Kota Pekalongan',
36
-    'Kota Salatiga',
37
-    'Kota Semarang',
38
-    'Kota Surakarta',
39
-    'Kota Tegal'
40
-
41
-    // 35
42
-];
43
-
44
-exports.seedJawaTengahCities = async () => {
45
-    const province = await prisma.province.findFirst({
46
-        where: { name: 'Jawa Tengah' },
47
-    });
48
-
49
-    if (!province) {
50
-        console.error('❌ Province Jawa Tengah not found. Seed it first.');
51
-        return;
52
-    }
53
-
54
-    for (const name of cityNames) {
55
-        await prisma.city.upsert({
56
-            where: {
57
-                name_province_id: {
58
-                    name,
59
-                    province_id: province.id,
60
-                },
61
-            },
62
-            update: {
63
-                updatedAt: timeLocal.now().toDate()
64
-            },
65
-            create: {
66
-                name,
67
-                province_id: province.id,
68
-                createdAt: timeLocal.now().toDate()
69
-            },
70
-        });
71
-    }
72
-
73
-    console.log('✅ Jawa Tengah City seeded!.');
74
-};

+ 147 - 0
prisma/seeders/city/JawaTengahCitySeeder.ts

@@ -0,0 +1,147 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Banjarnegara',
6
+    'Kabupaten Banyumas',
7
+    'Kabupaten Batang',
8
+    'Kabupaten Blora',
9
+    'Kabupaten Boyolali',
10
+    'Kabupaten Brebes',
11
+    'Kabupaten Cilacap',
12
+    'Kabupaten Demak',
13
+    'Kabupaten Grobogan',
14
+    'Kabupaten Jepara',
15
+    'Kabupaten Karanganyar',
16
+    'Kabupaten Kebumen',
17
+    'Kabupaten Kendal',
18
+    'Kabupaten Klaten',
19
+    'Kabupaten Kudus',
20
+    'Kabupaten Magelang',
21
+    'Kabupaten Pati',
22
+    'Kabupaten Pekalongan',
23
+    'Kabupaten Pemalang',
24
+    'Kabupaten Purbalingga',
25
+    'Kabupaten Purworejo',
26
+    'Kabupaten Rembang',
27
+    'Kabupaten Semarang',
28
+    'Kabupaten Sragen',
29
+    'Kabupaten Sukoharjo',
30
+    'Kabupaten Tegal',
31
+    'Kabupaten Temanggung',
32
+    'Kabupaten Wonogiri',
33
+    'Kabupaten Wonosobo',
34
+    'Kota Magelang',
35
+    'Kota Pekalongan',
36
+    'Kota Salatiga',
37
+    'Kota Semarang',
38
+    'Kota Surakarta',
39
+    'Kota Tegal'
40
+];
41
+
42
+export async function seedJawaTengahCities(): Promise<void> {
43
+    const province = await prisma.province.findFirst({
44
+        where: { name: 'Jawa Tengah' },
45
+    });
46
+
47
+    if (!province) {
48
+        console.error('❌ Province Jawa Tengah not found. Seed it first.');
49
+        return;
50
+    }
51
+
52
+    for (const name of cityNames) {
53
+        await prisma.city.upsert({
54
+            where: {
55
+                name_province_id: {
56
+                    name,
57
+                    province_id: province.id,
58
+                },
59
+            },
60
+            update: {
61
+                updatedAt: now().toDate(),
62
+            },
63
+            create: {
64
+                name,
65
+                province_id: province.id,
66
+                createdAt: now().toDate(),
67
+            },
68
+        });
69
+    }
70
+
71
+    console.log('✅ Jawa Tengah City seeded!');
72
+}
73
+
74
+// const prisma = require('../../../src/prisma/PrismaClient.js');
75
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
76
+
77
+// const cityNames = [
78
+//     'Kabupaten Banjarnegara',
79
+//     'Kabupaten Banyumas',
80
+//     'Kabupaten Batang',
81
+//     'Kabupaten Blora',
82
+//     'Kabupaten Boyolali',
83
+//     'Kabupaten Brebes',
84
+//     'Kabupaten Cilacap',
85
+//     'Kabupaten Demak',
86
+//     'Kabupaten Grobogan',
87
+//     'Kabupaten Jepara',
88
+//     'Kabupaten Karanganyar',
89
+//     'Kabupaten Kebumen',
90
+//     'Kabupaten Kendal',
91
+//     'Kabupaten Klaten',
92
+//     'Kabupaten Kudus',
93
+//     'Kabupaten Magelang',
94
+//     'Kabupaten Pati',
95
+//     'Kabupaten Pekalongan',
96
+//     'Kabupaten Pemalang',
97
+//     'Kabupaten Purbalingga',
98
+//     'Kabupaten Purworejo',
99
+//     'Kabupaten Rembang',
100
+//     'Kabupaten Semarang',
101
+//     'Kabupaten Sragen',
102
+//     'Kabupaten Sukoharjo',
103
+//     'Kabupaten Tegal',
104
+//     'Kabupaten Temanggung',
105
+//     'Kabupaten Wonogiri',
106
+//     'Kabupaten Wonosobo',
107
+//     'Kota Magelang',
108
+//     'Kota Pekalongan',
109
+//     'Kota Salatiga',
110
+//     'Kota Semarang',
111
+//     'Kota Surakarta',
112
+//     'Kota Tegal'
113
+
114
+//     // 35
115
+// ];
116
+
117
+// exports.seedJawaTengahCities = async () => {
118
+//     const province = await prisma.province.findFirst({
119
+//         where: { name: 'Jawa Tengah' },
120
+//     });
121
+
122
+//     if (!province) {
123
+//         console.error('❌ Province Jawa Tengah not found. Seed it first.');
124
+//         return;
125
+//     }
126
+
127
+//     for (const name of cityNames) {
128
+//         await prisma.city.upsert({
129
+//             where: {
130
+//                 name_province_id: {
131
+//                     name,
132
+//                     province_id: province.id,
133
+//                 },
134
+//             },
135
+//             update: {
136
+//                 updatedAt: timeLocal.now().toDate()
137
+//             },
138
+//             create: {
139
+//                 name,
140
+//                 province_id: province.id,
141
+//                 createdAt: timeLocal.now().toDate()
142
+//             },
143
+//         });
144
+//     }
145
+
146
+//     console.log('✅ Jawa Tengah City seeded!.');
147
+// };

+ 0 - 77
prisma/seeders/city/JawaTimurCitySeeder.js

@@ -1,77 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bangkalan',
6
-    'Kabupaten Banyuwangi',
7
-    'Kabupaten Blitar',
8
-    'Kabupaten Bojonegoro',
9
-    'Kabupaten Bondowoso',
10
-    'Kabupaten Gresik',
11
-    'Kabupaten Jember',
12
-    'Kabupaten Jombang',
13
-    'Kabupaten Kediri',
14
-    'Kabupaten Lamongan',
15
-    'Kabupaten Lumajang',
16
-    'Kabupaten Madiun',
17
-    'Kabupaten Magetan',
18
-    'Kabupaten Malang',
19
-    'Kabupaten Mojokerto',
20
-    'Kabupaten Nganjuk',
21
-    'Kabupaten Ngawi',
22
-    'Kabupaten Pacitan',
23
-    'Kabupaten Pamekasan',
24
-    'Kabupaten Pasuruan',
25
-    'Kabupaten Ponorogo',
26
-    'Kabupaten Probolinggo',
27
-    'Kabupaten Sampang',
28
-    'Kabupaten Sidoarjo',
29
-    'Kabupaten Situbondo',
30
-    'Kabupaten Sumenep',
31
-    'Kabupaten Trenggalek',
32
-    'Kabupaten Tuban',
33
-    'Kabupaten Tulungagung',
34
-    'Kota Batu',
35
-    'Kota Blitar',
36
-    'Kota Kediri',
37
-    'Kota Madiun',
38
-    'Kota Malang',
39
-    'Kota Mojokerto',
40
-    'Kota Pasuruan',
41
-    'Kota Probolinggo',
42
-    'Kota Surabaya'
43
-
44
-    // 38
45
-];
46
-
47
-exports.seedJawaTimurCities = async () => {
48
-    const province = await prisma.province.findFirst({
49
-        where: { name: 'Jawa Timur' },
50
-    });
51
-
52
-    if (!province) {
53
-        console.error('❌ Province Jawa Timur not found. Seed it first.');
54
-        return;
55
-    }
56
-
57
-    for (const name of cityNames) {
58
-        await prisma.city.upsert({
59
-            where: {
60
-                name_province_id: {
61
-                    name,
62
-                    province_id: province.id,
63
-                },
64
-            },
65
-            update: {
66
-                updatedAt: timeLocal.now().toDate()
67
-            },
68
-            create: {
69
-                name,
70
-                province_id: province.id,
71
-                createdAt: timeLocal.now().toDate()
72
-            },
73
-        });
74
-    }
75
-
76
-    console.log('✅ Jawa Timur City seeded!.');
77
-};

+ 153 - 0
prisma/seeders/city/JawaTimurCitySeeder.ts

@@ -0,0 +1,153 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bangkalan',
6
+    'Kabupaten Banyuwangi',
7
+    'Kabupaten Blitar',
8
+    'Kabupaten Bojonegoro',
9
+    'Kabupaten Bondowoso',
10
+    'Kabupaten Gresik',
11
+    'Kabupaten Jember',
12
+    'Kabupaten Jombang',
13
+    'Kabupaten Kediri',
14
+    'Kabupaten Lamongan',
15
+    'Kabupaten Lumajang',
16
+    'Kabupaten Madiun',
17
+    'Kabupaten Magetan',
18
+    'Kabupaten Malang',
19
+    'Kabupaten Mojokerto',
20
+    'Kabupaten Nganjuk',
21
+    'Kabupaten Ngawi',
22
+    'Kabupaten Pacitan',
23
+    'Kabupaten Pamekasan',
24
+    'Kabupaten Pasuruan',
25
+    'Kabupaten Ponorogo',
26
+    'Kabupaten Probolinggo',
27
+    'Kabupaten Sampang',
28
+    'Kabupaten Sidoarjo',
29
+    'Kabupaten Situbondo',
30
+    'Kabupaten Sumenep',
31
+    'Kabupaten Trenggalek',
32
+    'Kabupaten Tuban',
33
+    'Kabupaten Tulungagung',
34
+    'Kota Batu',
35
+    'Kota Blitar',
36
+    'Kota Kediri',
37
+    'Kota Madiun',
38
+    'Kota Malang',
39
+    'Kota Mojokerto',
40
+    'Kota Pasuruan',
41
+    'Kota Probolinggo',
42
+    'Kota Surabaya'
43
+];
44
+
45
+export async function seedJawaTimurCities(): Promise<void> {
46
+    const province = await prisma.province.findFirst({
47
+        where: { name: 'Jawa Timur' },
48
+    });
49
+
50
+    if (!province) {
51
+        console.error('❌ Province Jawa Timur not found. Seed it first.');
52
+        return;
53
+    }
54
+
55
+    for (const name of cityNames) {
56
+        await prisma.city.upsert({
57
+            where: {
58
+                name_province_id: {
59
+                    name,
60
+                    province_id: province.id,
61
+                },
62
+            },
63
+            update: {
64
+                updatedAt: now().toDate(),
65
+            },
66
+            create: {
67
+                name,
68
+                province_id: province.id,
69
+                createdAt: now().toDate(),
70
+            },
71
+        });
72
+    }
73
+
74
+    console.log('✅ Jawa Timur City seeded!');
75
+}
76
+
77
+// const prisma = require('../../../src/prisma/PrismaClient.js');
78
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
79
+
80
+// const cityNames = [
81
+//     'Kabupaten Bangkalan',
82
+//     'Kabupaten Banyuwangi',
83
+//     'Kabupaten Blitar',
84
+//     'Kabupaten Bojonegoro',
85
+//     'Kabupaten Bondowoso',
86
+//     'Kabupaten Gresik',
87
+//     'Kabupaten Jember',
88
+//     'Kabupaten Jombang',
89
+//     'Kabupaten Kediri',
90
+//     'Kabupaten Lamongan',
91
+//     'Kabupaten Lumajang',
92
+//     'Kabupaten Madiun',
93
+//     'Kabupaten Magetan',
94
+//     'Kabupaten Malang',
95
+//     'Kabupaten Mojokerto',
96
+//     'Kabupaten Nganjuk',
97
+//     'Kabupaten Ngawi',
98
+//     'Kabupaten Pacitan',
99
+//     'Kabupaten Pamekasan',
100
+//     'Kabupaten Pasuruan',
101
+//     'Kabupaten Ponorogo',
102
+//     'Kabupaten Probolinggo',
103
+//     'Kabupaten Sampang',
104
+//     'Kabupaten Sidoarjo',
105
+//     'Kabupaten Situbondo',
106
+//     'Kabupaten Sumenep',
107
+//     'Kabupaten Trenggalek',
108
+//     'Kabupaten Tuban',
109
+//     'Kabupaten Tulungagung',
110
+//     'Kota Batu',
111
+//     'Kota Blitar',
112
+//     'Kota Kediri',
113
+//     'Kota Madiun',
114
+//     'Kota Malang',
115
+//     'Kota Mojokerto',
116
+//     'Kota Pasuruan',
117
+//     'Kota Probolinggo',
118
+//     'Kota Surabaya'
119
+
120
+//     // 38
121
+// ];
122
+
123
+// exports.seedJawaTimurCities = async () => {
124
+//     const province = await prisma.province.findFirst({
125
+//         where: { name: 'Jawa Timur' },
126
+//     });
127
+
128
+//     if (!province) {
129
+//         console.error('❌ Province Jawa Timur not found. Seed it first.');
130
+//         return;
131
+//     }
132
+
133
+//     for (const name of cityNames) {
134
+//         await prisma.city.upsert({
135
+//             where: {
136
+//                 name_province_id: {
137
+//                     name,
138
+//                     province_id: province.id,
139
+//                 },
140
+//             },
141
+//             update: {
142
+//                 updatedAt: timeLocal.now().toDate()
143
+//             },
144
+//             create: {
145
+//                 name,
146
+//                 province_id: province.id,
147
+//                 createdAt: timeLocal.now().toDate()
148
+//             },
149
+//         });
150
+//     }
151
+
152
+//     console.log('✅ Jawa Timur City seeded!.');
153
+// };

+ 0 - 53
prisma/seeders/city/KalimantanBaratCitySeeder.js

@@ -1,53 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bengkayang',
6
-    'Kabupaten Kapuas Hulu',
7
-    'Kabupaten Kayong Utara',
8
-    'Kabupaten Ketapang',
9
-    'Kabupaten Kubu Raya',
10
-    'Kabupaten Landak',
11
-    'Kabupaten Melawi',
12
-    'Kabupaten Mempawah',
13
-    'Kabupaten Sambas',
14
-    'Kabupaten Sanggau',
15
-    'Kabupaten Sekadau',
16
-    'Kabupaten Sintang',
17
-    'Kota Pontianak',
18
-    'Kota Singkawang'
19
-
20
-    // 14
21
-];
22
-
23
-exports.seedKalimantanBaratCities = async () => {
24
-    const province = await prisma.province.findFirst({
25
-        where: { name: 'Kalimantan Barat' },
26
-    });
27
-
28
-    if (!province) {
29
-        console.error('❌ Province Kalimantan Barat not found. Seed it first.');
30
-        return;
31
-    }
32
-
33
-    for (const name of cityNames) {
34
-        await prisma.city.upsert({
35
-            where: {
36
-                name_province_id: {
37
-                    name,
38
-                    province_id: province.id,
39
-                },
40
-            },
41
-            update: {
42
-                updatedAt: timeLocal.now().toDate()
43
-            },
44
-            create: {
45
-                name,
46
-                province_id: province.id,
47
-                createdAt: timeLocal.now().toDate()
48
-            },
49
-        });
50
-    }
51
-
52
-    console.log('✅ Kalimantan Barat City seeded!.');
53
-};

+ 105 - 0
prisma/seeders/city/KalimantanBaratCitySeeder.ts

@@ -0,0 +1,105 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bengkayang',
6
+    'Kabupaten Kapuas Hulu',
7
+    'Kabupaten Kayong Utara',
8
+    'Kabupaten Ketapang',
9
+    'Kabupaten Kubu Raya',
10
+    'Kabupaten Landak',
11
+    'Kabupaten Melawi',
12
+    'Kabupaten Mempawah',
13
+    'Kabupaten Sambas',
14
+    'Kabupaten Sanggau',
15
+    'Kabupaten Sekadau',
16
+    'Kabupaten Sintang',
17
+    'Kota Pontianak',
18
+    'Kota Singkawang'
19
+];
20
+
21
+export async function seedKalimantanBaratCities(): Promise<void> {
22
+    const province = await prisma.province.findFirst({
23
+        where: { name: 'Kalimantan Barat' },
24
+    });
25
+
26
+    if (!province) {
27
+        console.error('❌ Province Kalimantan Barat not found. Seed it first.');
28
+        return;
29
+    }
30
+
31
+    for (const name of cityNames) {
32
+        await prisma.city.upsert({
33
+            where: {
34
+                name_province_id: {
35
+                    name,
36
+                    province_id: province.id,
37
+                },
38
+            },
39
+            update: {
40
+                updatedAt: now().toDate(),
41
+            },
42
+            create: {
43
+                name,
44
+                province_id: province.id,
45
+                createdAt: now().toDate(),
46
+            },
47
+        });
48
+    }
49
+
50
+    console.log('✅ Kalimantan Barat City seeded!');
51
+}
52
+
53
+// const prisma = require('../../../src/prisma/PrismaClient.js');
54
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
55
+
56
+// const cityNames = [
57
+//     'Kabupaten Bengkayang',
58
+//     'Kabupaten Kapuas Hulu',
59
+//     'Kabupaten Kayong Utara',
60
+//     'Kabupaten Ketapang',
61
+//     'Kabupaten Kubu Raya',
62
+//     'Kabupaten Landak',
63
+//     'Kabupaten Melawi',
64
+//     'Kabupaten Mempawah',
65
+//     'Kabupaten Sambas',
66
+//     'Kabupaten Sanggau',
67
+//     'Kabupaten Sekadau',
68
+//     'Kabupaten Sintang',
69
+//     'Kota Pontianak',
70
+//     'Kota Singkawang'
71
+
72
+//     // 14
73
+// ];
74
+
75
+// exports.seedKalimantanBaratCities = async () => {
76
+//     const province = await prisma.province.findFirst({
77
+//         where: { name: 'Kalimantan Barat' },
78
+//     });
79
+
80
+//     if (!province) {
81
+//         console.error('❌ Province Kalimantan Barat not found. Seed it first.');
82
+//         return;
83
+//     }
84
+
85
+//     for (const name of cityNames) {
86
+//         await prisma.city.upsert({
87
+//             where: {
88
+//                 name_province_id: {
89
+//                     name,
90
+//                     province_id: province.id,
91
+//                 },
92
+//             },
93
+//             update: {
94
+//                 updatedAt: timeLocal.now().toDate()
95
+//             },
96
+//             create: {
97
+//                 name,
98
+//                 province_id: province.id,
99
+//                 createdAt: timeLocal.now().toDate()
100
+//             },
101
+//         });
102
+//     }
103
+
104
+//     console.log('✅ Kalimantan Barat City seeded!.');
105
+// };

+ 0 - 52
prisma/seeders/city/KalimantanSelatanCitySeeder.js

@@ -1,52 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Balangan',
6
-    'Kabupaten Banjar',
7
-    'Kabupaten Barito Kuala',
8
-    'Kabupaten Hulu Sungai Selatan',
9
-    'Kabupaten Hulu Sungai Tengah',
10
-    'Kabupaten Hulu Sungai Utara',
11
-    'Kabupaten Kotabaru',
12
-    'Kabupaten Tabalong',
13
-    'Kabupaten Tanah Bumbu',
14
-    'Kabupaten Tanah Laut',
15
-    'Kabupaten Tapin',
16
-    'Kota Banjarbaru',
17
-    'Kota Banjarmasin'
18
-
19
-    // 13
20
-];
21
-
22
-exports.seedKalimantanSelatanCities = async () => {
23
-    const province = await prisma.province.findFirst({
24
-        where: { name: 'Kalimantan Selatan' },
25
-    });
26
-
27
-    if (!province) {
28
-        console.error('❌ Province Kalimantan Selatan not found. Seed it first.');
29
-        return;
30
-    }
31
-
32
-    for (const name of cityNames) {
33
-        await prisma.city.upsert({
34
-            where: {
35
-                name_province_id: {
36
-                    name,
37
-                    province_id: province.id,
38
-                },
39
-            },
40
-            update: {
41
-                updatedAt: timeLocal.now().toDate()
42
-            },
43
-            create: {
44
-                name,
45
-                province_id: province.id,
46
-                createdAt: timeLocal.now().toDate()
47
-            },
48
-        });
49
-    }
50
-
51
-    console.log('✅ Kalimantan Selatan City seeded!.');
52
-};

+ 103 - 0
prisma/seeders/city/KalimantanSelatanCitySeeder.ts

@@ -0,0 +1,103 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Balangan',
6
+    'Kabupaten Banjar',
7
+    'Kabupaten Barito Kuala',
8
+    'Kabupaten Hulu Sungai Selatan',
9
+    'Kabupaten Hulu Sungai Tengah',
10
+    'Kabupaten Hulu Sungai Utara',
11
+    'Kabupaten Kotabaru',
12
+    'Kabupaten Tabalong',
13
+    'Kabupaten Tanah Bumbu',
14
+    'Kabupaten Tanah Laut',
15
+    'Kabupaten Tapin',
16
+    'Kota Banjarbaru',
17
+    'Kota Banjarmasin'
18
+];
19
+
20
+export async function seedKalimantanSelatanCities(): Promise<void> {
21
+    const province = await prisma.province.findFirst({
22
+        where: { name: 'Kalimantan Selatan' },
23
+    });
24
+
25
+    if (!province) {
26
+        console.error('❌ Province Kalimantan Selatan not found. Seed it first.');
27
+        return;
28
+    }
29
+
30
+    for (const name of cityNames) {
31
+        await prisma.city.upsert({
32
+            where: {
33
+                name_province_id: {
34
+                    name,
35
+                    province_id: province.id,
36
+                },
37
+            },
38
+            update: {
39
+                updatedAt: now().toDate(),
40
+            },
41
+            create: {
42
+                name,
43
+                province_id: province.id,
44
+                createdAt: now().toDate(),
45
+            },
46
+        });
47
+    }
48
+
49
+    console.log('✅ Kalimantan Selatan City seeded!');
50
+}
51
+
52
+// const prisma = require('../../../src/prisma/PrismaClient.js');
53
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
54
+
55
+// const cityNames = [
56
+//     'Kabupaten Balangan',
57
+//     'Kabupaten Banjar',
58
+//     'Kabupaten Barito Kuala',
59
+//     'Kabupaten Hulu Sungai Selatan',
60
+//     'Kabupaten Hulu Sungai Tengah',
61
+//     'Kabupaten Hulu Sungai Utara',
62
+//     'Kabupaten Kotabaru',
63
+//     'Kabupaten Tabalong',
64
+//     'Kabupaten Tanah Bumbu',
65
+//     'Kabupaten Tanah Laut',
66
+//     'Kabupaten Tapin',
67
+//     'Kota Banjarbaru',
68
+//     'Kota Banjarmasin'
69
+
70
+//     // 13
71
+// ];
72
+
73
+// exports.seedKalimantanSelatanCities = async () => {
74
+//     const province = await prisma.province.findFirst({
75
+//         where: { name: 'Kalimantan Selatan' },
76
+//     });
77
+
78
+//     if (!province) {
79
+//         console.error('❌ Province Kalimantan Selatan not found. Seed it first.');
80
+//         return;
81
+//     }
82
+
83
+//     for (const name of cityNames) {
84
+//         await prisma.city.upsert({
85
+//             where: {
86
+//                 name_province_id: {
87
+//                     name,
88
+//                     province_id: province.id,
89
+//                 },
90
+//             },
91
+//             update: {
92
+//                 updatedAt: timeLocal.now().toDate()
93
+//             },
94
+//             create: {
95
+//                 name,
96
+//                 province_id: province.id,
97
+//                 createdAt: timeLocal.now().toDate()
98
+//             },
99
+//         });
100
+//     }
101
+
102
+//     console.log('✅ Kalimantan Selatan City seeded!.');
103
+// };

+ 0 - 53
prisma/seeders/city/KalimantanTengahCitySeeder.js

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

+ 105 - 0
prisma/seeders/city/KalimantanTengahCitySeeder.ts

@@ -0,0 +1,105 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Barito Selatan',
6
+    'Kabupaten Barito Timur',
7
+    'Kabupaten Barito Utara',
8
+    'Kabupaten Gunung Mas',
9
+    'Kabupaten Kapuas',
10
+    'Kabupaten Katingan',
11
+    'Kabupaten Kotawaringin Barat',
12
+    'Kabupaten Kotawaringin Timur',
13
+    'Kabupaten Lamandau',
14
+    'Kabupaten Murung Raya',
15
+    'Kabupaten Pulang Pisau',
16
+    'Kabupaten Sukamara',
17
+    'Kabupaten Seruyan',
18
+    'Kota Palangka Raya'
19
+];
20
+
21
+export async function seedKalimantanTengahCities(): Promise<void> {
22
+    const province = await prisma.province.findFirst({
23
+        where: { name: 'Kalimantan Tengah' },
24
+    });
25
+
26
+    if (!province) {
27
+        console.error('❌ Province Kalimantan Tengah not found. Seed it first.');
28
+        return;
29
+    }
30
+
31
+    for (const name of cityNames) {
32
+        await prisma.city.upsert({
33
+            where: {
34
+                name_province_id: {
35
+                    name,
36
+                    province_id: province.id,
37
+                },
38
+            },
39
+            update: {
40
+                updatedAt: now().toDate(),
41
+            },
42
+            create: {
43
+                name,
44
+                province_id: province.id,
45
+                createdAt: now().toDate(),
46
+            },
47
+        });
48
+    }
49
+
50
+    console.log('✅ Kalimantan Tengah City seeded!');
51
+}
52
+
53
+// const prisma = require('../../../src/prisma/PrismaClient.js');
54
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
55
+
56
+// const cityNames = [
57
+//     'Kabupaten Barito Selatan',
58
+//     'Kabupaten Barito Timur',
59
+//     'Kabupaten Barito Utara',
60
+//     'Kabupaten Gunung Mas',
61
+//     'Kabupaten Kapuas',
62
+//     'Kabupaten Katingan',
63
+//     'Kabupaten Kotawaringin Barat',
64
+//     'Kabupaten Kotawaringin Timur',
65
+//     'Kabupaten Lamandau',
66
+//     'Kabupaten Murung Raya',
67
+//     'Kabupaten Pulang Pisau',
68
+//     'Kabupaten Sukamara',
69
+//     'Kabupaten Seruyan',
70
+//     'Kota Palangka Raya'
71
+
72
+//     // 14
73
+// ];
74
+
75
+// exports.seedKalimantanTengahCities = async () => {
76
+//     const province = await prisma.province.findFirst({
77
+//         where: { name: 'Kalimantan Tengah' },
78
+//     });
79
+
80
+//     if (!province) {
81
+//         console.error('❌ Province Kalimantan Tengah not found. Seed it first.');
82
+//         return;
83
+//     }
84
+
85
+//     for (const name of cityNames) {
86
+//         await prisma.city.upsert({
87
+//             where: {
88
+//                 name_province_id: {
89
+//                     name,
90
+//                     province_id: province.id,
91
+//                 },
92
+//             },
93
+//             update: {
94
+//                 updatedAt: timeLocal.now().toDate()
95
+//             },
96
+//             create: {
97
+//                 name,
98
+//                 province_id: province.id,
99
+//                 createdAt: timeLocal.now().toDate()
100
+//             },
101
+//         });
102
+//     }
103
+
104
+//     console.log('✅ Kalimantan Tengah City seeded!.');
105
+// };

+ 0 - 49
prisma/seeders/city/KalimantanTimurCitySeeder.js

@@ -1,49 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Berau',
6
-    'Kabupaten Kutai Barat',
7
-    'Kabupaten Kutai Kartanegara',
8
-    'Kabupaten Kutai Timur',
9
-    'Kabupaten Mahakam Ulu',
10
-    'Kabupaten Paser',
11
-    'Kabupaten Penajam Paser Utara',
12
-    'Kota Balikpapan',
13
-    'Kota Bontang',
14
-    'Kota Samarinda'
15
-
16
-    // 10
17
-];
18
-
19
-exports.seedKalimantanTimurCities = async () => {
20
-    const province = await prisma.province.findFirst({
21
-        where: { name: 'Kalimantan Timur' },
22
-    });
23
-
24
-    if (!province) {
25
-        console.error('❌ Province Kalimantan Timur not found. Seed it first.');
26
-        return;
27
-    }
28
-
29
-    for (const name of cityNames) {
30
-        await prisma.city.upsert({
31
-            where: {
32
-                name_province_id: {
33
-                    name,
34
-                    province_id: province.id,
35
-                },
36
-            },
37
-            update: {
38
-                updatedAt: timeLocal.now().toDate()
39
-            },
40
-            create: {
41
-                name,
42
-                province_id: province.id,
43
-                createdAt: timeLocal.now().toDate()
44
-            },
45
-        });
46
-    }
47
-
48
-    console.log('✅ Kalimantan Timur City seeded!.');
49
-};

+ 98 - 0
prisma/seeders/city/KalimantanTimurCitySeeder.ts

@@ -0,0 +1,98 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Berau',
6
+    'Kabupaten Kutai Barat',
7
+    'Kabupaten Kutai Kartanegara',
8
+    'Kabupaten Kutai Timur',
9
+    'Kabupaten Mahakam Ulu',
10
+    'Kabupaten Paser',
11
+    'Kabupaten Penajam Paser Utara',
12
+    'Kota Balikpapan',
13
+    'Kota Bontang',
14
+    'Kota Samarinda'
15
+];
16
+
17
+export async function seedKalimantanTimurCities(): Promise<void> {
18
+    const province = await prisma.province.findFirst({
19
+        where: { name: 'Kalimantan Timur' },
20
+    });
21
+
22
+    if (!province) {
23
+        console.error('❌ Province Kalimantan Timur not found. Seed it first.');
24
+        return;
25
+    }
26
+
27
+    for (const name of cityNames) {
28
+        await prisma.city.upsert({
29
+            where: {
30
+                name_province_id: {
31
+                    name,
32
+                    province_id: province.id,
33
+                },
34
+            },
35
+            update: {
36
+                updatedAt: now().toDate(),
37
+            },
38
+            create: {
39
+                name,
40
+                province_id: province.id,
41
+                createdAt: now().toDate(),
42
+            },
43
+        });
44
+    }
45
+
46
+    console.log('✅ Kalimantan Timur City seeded!');
47
+}
48
+
49
+
50
+// const prisma = require('../../../src/prisma/PrismaClient.js');
51
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
52
+
53
+// const cityNames = [
54
+//     'Kabupaten Berau',
55
+//     'Kabupaten Kutai Barat',
56
+//     'Kabupaten Kutai Kartanegara',
57
+//     'Kabupaten Kutai Timur',
58
+//     'Kabupaten Mahakam Ulu',
59
+//     'Kabupaten Paser',
60
+//     'Kabupaten Penajam Paser Utara',
61
+//     'Kota Balikpapan',
62
+//     'Kota Bontang',
63
+//     'Kota Samarinda'
64
+
65
+//     // 10
66
+// ];
67
+
68
+// exports.seedKalimantanTimurCities = async () => {
69
+//     const province = await prisma.province.findFirst({
70
+//         where: { name: 'Kalimantan Timur' },
71
+//     });
72
+
73
+//     if (!province) {
74
+//         console.error('❌ Province Kalimantan Timur not found. Seed it first.');
75
+//         return;
76
+//     }
77
+
78
+//     for (const name of cityNames) {
79
+//         await prisma.city.upsert({
80
+//             where: {
81
+//                 name_province_id: {
82
+//                     name,
83
+//                     province_id: province.id,
84
+//                 },
85
+//             },
86
+//             update: {
87
+//                 updatedAt: timeLocal.now().toDate()
88
+//             },
89
+//             create: {
90
+//                 name,
91
+//                 province_id: province.id,
92
+//                 createdAt: timeLocal.now().toDate()
93
+//             },
94
+//         });
95
+//     }
96
+
97
+//     console.log('✅ Kalimantan Timur City seeded!.');
98
+// };

+ 0 - 44
prisma/seeders/city/KalimantanUtaraCitySeeder.js

@@ -1,44 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bulungan',
6
-    'Kabupaten Malinau',
7
-    'Kabupaten Nunukan',
8
-    'Kabupaten Tana Tidung',
9
-    'Kota Tarakan'
10
-
11
-    // 5
12
-];
13
-
14
-exports.seedKalimantanUtaraCities = async () => {
15
-    const province = await prisma.province.findFirst({
16
-        where: { name: 'Kalimantan Utara' },
17
-    });
18
-
19
-    if (!province) {
20
-        console.error('❌ Province Kalimantan Utara not found. Seed it first.');
21
-        return;
22
-    }
23
-
24
-    for (const name of cityNames) {
25
-        await prisma.city.upsert({
26
-            where: {
27
-                name_province_id: {
28
-                    name,
29
-                    province_id: province.id,
30
-                },
31
-            },
32
-            update: {
33
-                updatedAt: timeLocal.now().toDate()
34
-            },
35
-            create: {
36
-                name,
37
-                province_id: province.id,
38
-                createdAt: timeLocal.now().toDate()
39
-            },
40
-        });
41
-    }
42
-
43
-    console.log('✅ Kalimantan Utara City seeded!.');
44
-};

+ 87 - 0
prisma/seeders/city/KalimantanUtaraCitySeeder.ts

@@ -0,0 +1,87 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bulungan',
6
+    'Kabupaten Malinau',
7
+    'Kabupaten Nunukan',
8
+    'Kabupaten Tana Tidung',
9
+    'Kota Tarakan'
10
+];
11
+
12
+export async function seedKalimantanUtaraCities(): Promise<void> {
13
+    const province = await prisma.province.findFirst({
14
+        where: { name: 'Kalimantan Utara' },
15
+    });
16
+
17
+    if (!province) {
18
+        console.error('❌ Province Kalimantan Utara not found. Seed it first.');
19
+        return;
20
+    }
21
+
22
+    for (const name of cityNames) {
23
+        await prisma.city.upsert({
24
+            where: {
25
+                name_province_id: {
26
+                    name,
27
+                    province_id: province.id,
28
+                },
29
+            },
30
+            update: {
31
+                updatedAt: now().toDate(),
32
+            },
33
+            create: {
34
+                name,
35
+                province_id: province.id,
36
+                createdAt: now().toDate(),
37
+            },
38
+        });
39
+    }
40
+
41
+    console.log('✅ Kalimantan Utara City seeded!');
42
+}
43
+
44
+// const prisma = require('../../../src/prisma/PrismaClient.js');
45
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
46
+
47
+// const cityNames = [
48
+//     'Kabupaten Bulungan',
49
+//     'Kabupaten Malinau',
50
+//     'Kabupaten Nunukan',
51
+//     'Kabupaten Tana Tidung',
52
+//     'Kota Tarakan'
53
+
54
+//     // 5
55
+// ];
56
+
57
+// exports.seedKalimantanUtaraCities = async () => {
58
+//     const province = await prisma.province.findFirst({
59
+//         where: { name: 'Kalimantan Utara' },
60
+//     });
61
+
62
+//     if (!province) {
63
+//         console.error('❌ Province Kalimantan Utara not found. Seed it first.');
64
+//         return;
65
+//     }
66
+
67
+//     for (const name of cityNames) {
68
+//         await prisma.city.upsert({
69
+//             where: {
70
+//                 name_province_id: {
71
+//                     name,
72
+//                     province_id: province.id,
73
+//                 },
74
+//             },
75
+//             update: {
76
+//                 updatedAt: timeLocal.now().toDate()
77
+//             },
78
+//             create: {
79
+//                 name,
80
+//                 province_id: province.id,
81
+//                 createdAt: timeLocal.now().toDate()
82
+//             },
83
+//         });
84
+//     }
85
+
86
+//     console.log('✅ Kalimantan Utara City seeded!.');
87
+// };

+ 0 - 46
prisma/seeders/city/KepulauanBangkaBelitungCitySeeder.js

@@ -1,46 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bangka',
6
-    'Kabupaten Bangka Barat',
7
-    'Kabupaten Bangka Selatan',
8
-    'Kabupaten Bangka Tengah',
9
-    'Kabupaten Belitung',
10
-    'Kabupaten Belitung Timur',
11
-    'Kota Pangkal Pinang'
12
-
13
-    // 7
14
-];
15
-
16
-exports.seedKepulauanBangkaBelitungCities = async () => {
17
-    const province = await prisma.province.findFirst({
18
-        where: { name: 'Kepulauan Bangka Belitung' },
19
-    });
20
-
21
-    if (!province) {
22
-        console.error('❌ Province Kepulauan Bangka Belitung not found. Seed it first.');
23
-        return;
24
-    }
25
-
26
-    for (const name of cityNames) {
27
-        await prisma.city.upsert({
28
-            where: {
29
-                name_province_id: {
30
-                    name,
31
-                    province_id: province.id,
32
-                },
33
-            },
34
-            update: {
35
-                updatedAt: timeLocal.now().toDate()
36
-            },
37
-            create: {
38
-                name,
39
-                province_id: province.id,
40
-                createdAt: timeLocal.now().toDate()
41
-            },
42
-        });
43
-    }
44
-
45
-    console.log('✅ Kepulauan Bangka Belitung City seeded!.');
46
-};

+ 91 - 0
prisma/seeders/city/KepulauanBangkaBelitungCitySeeder.ts

@@ -0,0 +1,91 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bangka',
6
+    'Kabupaten Bangka Barat',
7
+    'Kabupaten Bangka Selatan',
8
+    'Kabupaten Bangka Tengah',
9
+    'Kabupaten Belitung',
10
+    'Kabupaten Belitung Timur',
11
+    'Kota Pangkal Pinang'
12
+];
13
+
14
+export async function seedKepulauanBangkaBelitungCities(): Promise<void> {
15
+    const province = await prisma.province.findFirst({
16
+        where: { name: 'Kepulauan Bangka Belitung' },
17
+    });
18
+
19
+    if (!province) {
20
+        console.error('❌ Province Kepulauan Bangka Belitung not found. Seed it first.');
21
+        return;
22
+    }
23
+
24
+    for (const name of cityNames) {
25
+        await prisma.city.upsert({
26
+            where: {
27
+                name_province_id: {
28
+                    name,
29
+                    province_id: province.id,
30
+                },
31
+            },
32
+            update: {
33
+                updatedAt: now().toDate(),
34
+            },
35
+            create: {
36
+                name,
37
+                province_id: province.id,
38
+                createdAt: now().toDate(),
39
+            },
40
+        });
41
+    }
42
+
43
+    console.log('✅ Kepulauan Bangka Belitung City seeded!');
44
+}
45
+
46
+// const prisma = require('../../../src/prisma/PrismaClient.js');
47
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
48
+
49
+// const cityNames = [
50
+//     'Kabupaten Bangka',
51
+//     'Kabupaten Bangka Barat',
52
+//     'Kabupaten Bangka Selatan',
53
+//     'Kabupaten Bangka Tengah',
54
+//     'Kabupaten Belitung',
55
+//     'Kabupaten Belitung Timur',
56
+//     'Kota Pangkal Pinang'
57
+
58
+//     // 7
59
+// ];
60
+
61
+// exports.seedKepulauanBangkaBelitungCities = async () => {
62
+//     const province = await prisma.province.findFirst({
63
+//         where: { name: 'Kepulauan Bangka Belitung' },
64
+//     });
65
+
66
+//     if (!province) {
67
+//         console.error('❌ Province Kepulauan Bangka Belitung not found. Seed it first.');
68
+//         return;
69
+//     }
70
+
71
+//     for (const name of cityNames) {
72
+//         await prisma.city.upsert({
73
+//             where: {
74
+//                 name_province_id: {
75
+//                     name,
76
+//                     province_id: province.id,
77
+//                 },
78
+//             },
79
+//             update: {
80
+//                 updatedAt: timeLocal.now().toDate()
81
+//             },
82
+//             create: {
83
+//                 name,
84
+//                 province_id: province.id,
85
+//                 createdAt: timeLocal.now().toDate()
86
+//             },
87
+//         });
88
+//     }
89
+
90
+//     console.log('✅ Kepulauan Bangka Belitung City seeded!.');
91
+// };

+ 0 - 46
prisma/seeders/city/KepulauanRiauCitySeeder.js

@@ -1,46 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bintan',
6
-    'Kabupaten Karimun',
7
-    'Kabupaten Kepulauan Anambas',
8
-    'Kabupaten Lingga',
9
-    'Kabupaten Natuna',
10
-    'Kota Batam',
11
-    'Kota Tanjung Pinang'
12
-
13
-    // 7
14
-];
15
-
16
-exports.seedKepulauanRiauCities = async () => {
17
-    const province = await prisma.province.findFirst({
18
-        where: { name: 'Kepulauan Riau' },
19
-    });
20
-
21
-    if (!province) {
22
-        console.error('❌ Province Kepulauan Riau not found. Seed it first.');
23
-        return;
24
-    }
25
-
26
-    for (const name of cityNames) {
27
-        await prisma.city.upsert({
28
-            where: {
29
-                name_province_id: {
30
-                    name,
31
-                    province_id: province.id,
32
-                },
33
-            },
34
-            update: {
35
-                updatedAt: timeLocal.now().toDate()
36
-            },
37
-            create: {
38
-                name,
39
-                province_id: province.id,
40
-                createdAt: timeLocal.now().toDate()
41
-            },
42
-        });
43
-    }
44
-
45
-    console.log('✅ Kepulauan Riau City seeded!.');
46
-};

+ 91 - 0
prisma/seeders/city/KepulauanRiauCitySeeder.ts

@@ -0,0 +1,91 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bintan',
6
+    'Kabupaten Karimun',
7
+    'Kabupaten Kepulauan Anambas',
8
+    'Kabupaten Lingga',
9
+    'Kabupaten Natuna',
10
+    'Kota Batam',
11
+    'Kota Tanjung Pinang'
12
+];
13
+
14
+export async function seedKepulauanRiauCities(): Promise<void> {
15
+    const province = await prisma.province.findFirst({
16
+        where: { name: 'Kepulauan Riau' },
17
+    });
18
+
19
+    if (!province) {
20
+        console.error('❌ Province Kepulauan Riau not found. Seed it first.');
21
+        return;
22
+    }
23
+
24
+    for (const name of cityNames) {
25
+        await prisma.city.upsert({
26
+            where: {
27
+                name_province_id: {
28
+                    name,
29
+                    province_id: province.id,
30
+                },
31
+            },
32
+            update: {
33
+                updatedAt: now().toDate(),
34
+            },
35
+            create: {
36
+                name,
37
+                province_id: province.id,
38
+                createdAt: now().toDate(),
39
+            },
40
+        });
41
+    }
42
+
43
+    console.log('✅ Kepulauan Riau City seeded!');
44
+}
45
+
46
+// const prisma = require('../../../src/prisma/PrismaClient.js');
47
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
48
+
49
+// const cityNames = [
50
+//     'Kabupaten Bintan',
51
+//     'Kabupaten Karimun',
52
+//     'Kabupaten Kepulauan Anambas',
53
+//     'Kabupaten Lingga',
54
+//     'Kabupaten Natuna',
55
+//     'Kota Batam',
56
+//     'Kota Tanjung Pinang'
57
+
58
+//     // 7
59
+// ];
60
+
61
+// exports.seedKepulauanRiauCities = async () => {
62
+//     const province = await prisma.province.findFirst({
63
+//         where: { name: 'Kepulauan Riau' },
64
+//     });
65
+
66
+//     if (!province) {
67
+//         console.error('❌ Province Kepulauan Riau not found. Seed it first.');
68
+//         return;
69
+//     }
70
+
71
+//     for (const name of cityNames) {
72
+//         await prisma.city.upsert({
73
+//             where: {
74
+//                 name_province_id: {
75
+//                     name,
76
+//                     province_id: province.id,
77
+//                 },
78
+//             },
79
+//             update: {
80
+//                 updatedAt: timeLocal.now().toDate()
81
+//             },
82
+//             create: {
83
+//                 name,
84
+//                 province_id: province.id,
85
+//                 createdAt: timeLocal.now().toDate()
86
+//             },
87
+//         });
88
+//     }
89
+
90
+//     console.log('✅ Kepulauan Riau City seeded!.');
91
+// };

+ 0 - 54
prisma/seeders/city/LampungCitySeeder.js

@@ -1,54 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Lampung Barat',
6
-    'Kabupaten Lampung Selatan',
7
-    'Kabupaten Lampung Tengah',
8
-    'Kabupaten Lampung Timur',
9
-    'Kabupaten Lampung Utara',
10
-    'Kabupaten Mesuji',
11
-    'Kabupaten Pesawaran',
12
-    'Kabupaten Pesisir Barat',
13
-    'Kabupaten Pringsewu',
14
-    'Kabupaten Tanggamus',
15
-    'Kabupaten Tulang Bawang',
16
-    'Kabupaten Tulang Bawang Barat',
17
-    'Kabupaten Way Kanan',
18
-    'Kota Bandar Lampung',
19
-    'Kota Metro'
20
-
21
-    // 15
22
-];
23
-
24
-exports.seedLampungCities = async () => {
25
-    const province = await prisma.province.findFirst({
26
-        where: { name: 'Lampung' },
27
-    });
28
-
29
-    if (!province) {
30
-        console.error('❌ Province Lampung not found. Seed it first.');
31
-        return;
32
-    }
33
-
34
-    for (const name of cityNames) {
35
-        await prisma.city.upsert({
36
-            where: {
37
-                name_province_id: {
38
-                    name,
39
-                    province_id: province.id,
40
-                },
41
-            },
42
-            update: {
43
-                updatedAt: timeLocal.now().toDate()
44
-            },
45
-            create: {
46
-                name,
47
-                province_id: province.id,
48
-                createdAt: timeLocal.now().toDate()
49
-            },
50
-        });
51
-    }
52
-
53
-    console.log('✅ Lampung City seeded!.');
54
-};

+ 107 - 0
prisma/seeders/city/LampungCitySeeder.ts

@@ -0,0 +1,107 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Lampung Barat',
6
+    'Kabupaten Lampung Selatan',
7
+    'Kabupaten Lampung Tengah',
8
+    'Kabupaten Lampung Timur',
9
+    'Kabupaten Lampung Utara',
10
+    'Kabupaten Mesuji',
11
+    'Kabupaten Pesawaran',
12
+    'Kabupaten Pesisir Barat',
13
+    'Kabupaten Pringsewu',
14
+    'Kabupaten Tanggamus',
15
+    'Kabupaten Tulang Bawang',
16
+    'Kabupaten Tulang Bawang Barat',
17
+    'Kabupaten Way Kanan',
18
+    'Kota Bandar Lampung',
19
+    'Kota Metro'
20
+];
21
+
22
+export async function seedLampungCities(): Promise<void> {
23
+    const province = await prisma.province.findFirst({
24
+        where: { name: 'Lampung' },
25
+    });
26
+
27
+    if (!province) {
28
+        console.error('❌ Province Lampung not found. Seed it first.');
29
+        return;
30
+    }
31
+
32
+    for (const name of cityNames) {
33
+        await prisma.city.upsert({
34
+            where: {
35
+                name_province_id: {
36
+                    name,
37
+                    province_id: province.id,
38
+                },
39
+            },
40
+            update: {
41
+                updatedAt: now().toDate(),
42
+            },
43
+            create: {
44
+                name,
45
+                province_id: province.id,
46
+                createdAt: now().toDate(),
47
+            },
48
+        });
49
+    }
50
+
51
+    console.log('✅ Lampung City seeded!');
52
+}
53
+
54
+// const prisma = require('../../../src/prisma/PrismaClient.js');
55
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
56
+
57
+// const cityNames = [
58
+//     'Kabupaten Lampung Barat',
59
+//     'Kabupaten Lampung Selatan',
60
+//     'Kabupaten Lampung Tengah',
61
+//     'Kabupaten Lampung Timur',
62
+//     'Kabupaten Lampung Utara',
63
+//     'Kabupaten Mesuji',
64
+//     'Kabupaten Pesawaran',
65
+//     'Kabupaten Pesisir Barat',
66
+//     'Kabupaten Pringsewu',
67
+//     'Kabupaten Tanggamus',
68
+//     'Kabupaten Tulang Bawang',
69
+//     'Kabupaten Tulang Bawang Barat',
70
+//     'Kabupaten Way Kanan',
71
+//     'Kota Bandar Lampung',
72
+//     'Kota Metro'
73
+
74
+//     // 15
75
+// ];
76
+
77
+// exports.seedLampungCities = async () => {
78
+//     const province = await prisma.province.findFirst({
79
+//         where: { name: 'Lampung' },
80
+//     });
81
+
82
+//     if (!province) {
83
+//         console.error('❌ Province Lampung not found. Seed it first.');
84
+//         return;
85
+//     }
86
+
87
+//     for (const name of cityNames) {
88
+//         await prisma.city.upsert({
89
+//             where: {
90
+//                 name_province_id: {
91
+//                     name,
92
+//                     province_id: province.id,
93
+//                 },
94
+//             },
95
+//             update: {
96
+//                 updatedAt: timeLocal.now().toDate()
97
+//             },
98
+//             create: {
99
+//                 name,
100
+//                 province_id: province.id,
101
+//                 createdAt: timeLocal.now().toDate()
102
+//             },
103
+//         });
104
+//     }
105
+
106
+//     console.log('✅ Lampung City seeded!.');
107
+// };

+ 0 - 50
prisma/seeders/city/MalukuCitySeeder.js

@@ -1,50 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Buru',
6
-    'Kabupaten Buru Selatan',
7
-    'Kabupaten Kepulauan Aru',
8
-    'Kabupaten Maluku Barat Daya',
9
-    'Kabupaten Maluku Tengah',
10
-    'Kabupaten Maluku Tenggara',
11
-    'Kabupaten Seram Bagian Barat',
12
-    'Kabupaten Seram Bagian Timur',
13
-    'Kota Ambon',
14
-    'Kota Tual',
15
-    'Kabupaten Maluku Tenggara Barat'
16
-
17
-    // 11
18
-];
19
-
20
-exports.seedMalukuCities = async () => {
21
-    const province = await prisma.province.findFirst({
22
-        where: { name: 'Maluku' },
23
-    });
24
-
25
-    if (!province) {
26
-        console.error('❌ Province Maluku not found. Seed it first.');
27
-        return;
28
-    }
29
-
30
-    for (const name of cityNames) {
31
-        await prisma.city.upsert({
32
-            where: {
33
-                name_province_id: {
34
-                    name,
35
-                    province_id: province.id,
36
-                },
37
-            },
38
-            update: {
39
-                updatedAt: timeLocal.now().toDate()
40
-            },
41
-            create: {
42
-                name,
43
-                province_id: province.id,
44
-                createdAt: timeLocal.now().toDate()
45
-            },
46
-        });
47
-    }
48
-
49
-    console.log('✅ Maluku City seeded!.');
50
-};

+ 99 - 0
prisma/seeders/city/MalukuCitySeeder.ts

@@ -0,0 +1,99 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Buru',
6
+    'Kabupaten Buru Selatan',
7
+    'Kabupaten Kepulauan Aru',
8
+    'Kabupaten Maluku Barat Daya',
9
+    'Kabupaten Maluku Tengah',
10
+    'Kabupaten Maluku Tenggara',
11
+    'Kabupaten Seram Bagian Barat',
12
+    'Kabupaten Seram Bagian Timur',
13
+    'Kota Ambon',
14
+    'Kota Tual',
15
+    'Kabupaten Maluku Tenggara Barat'
16
+];
17
+
18
+export async function seedMalukuCities(): Promise<void> {
19
+    const province = await prisma.province.findFirst({
20
+        where: { name: 'Maluku' },
21
+    });
22
+
23
+    if (!province) {
24
+        console.error('❌ Province Maluku not found. Seed it first.');
25
+        return;
26
+    }
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: now().toDate(),
38
+            },
39
+            create: {
40
+                name,
41
+                province_id: province.id,
42
+                createdAt: now().toDate(),
43
+            },
44
+        });
45
+    }
46
+
47
+    console.log('✅ Maluku City seeded!');
48
+}
49
+
50
+// const prisma = require('../../../src/prisma/PrismaClient.js');
51
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
52
+
53
+// const cityNames = [
54
+//     'Kabupaten Buru',
55
+//     'Kabupaten Buru Selatan',
56
+//     'Kabupaten Kepulauan Aru',
57
+//     'Kabupaten Maluku Barat Daya',
58
+//     'Kabupaten Maluku Tengah',
59
+//     'Kabupaten Maluku Tenggara',
60
+//     'Kabupaten Seram Bagian Barat',
61
+//     'Kabupaten Seram Bagian Timur',
62
+//     'Kota Ambon',
63
+//     'Kota Tual',
64
+//     'Kabupaten Maluku Tenggara Barat'
65
+
66
+//     // 11
67
+// ];
68
+
69
+// exports.seedMalukuCities = async () => {
70
+//     const province = await prisma.province.findFirst({
71
+//         where: { name: 'Maluku' },
72
+//     });
73
+
74
+//     if (!province) {
75
+//         console.error('❌ Province Maluku not found. Seed it first.');
76
+//         return;
77
+//     }
78
+
79
+//     for (const name of cityNames) {
80
+//         await prisma.city.upsert({
81
+//             where: {
82
+//                 name_province_id: {
83
+//                     name,
84
+//                     province_id: province.id,
85
+//                 },
86
+//             },
87
+//             update: {
88
+//                 updatedAt: timeLocal.now().toDate()
89
+//             },
90
+//             create: {
91
+//                 name,
92
+//                 province_id: province.id,
93
+//                 createdAt: timeLocal.now().toDate()
94
+//             },
95
+//         });
96
+//     }
97
+
98
+//     console.log('✅ Maluku City seeded!.');
99
+// };

+ 0 - 49
prisma/seeders/city/MalukuUtaraCitySeeder.js

@@ -1,49 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Halmahera Barat',
6
-    'Kabupaten Halmahera Tengah',
7
-    'Kabupaten Halmahera Timur',
8
-    'Kabupaten Halmahera Selatan',
9
-    'Kabupaten Halmahera Utara',
10
-    'Kabupaten Kepulauan Sula',
11
-    'Kabupaten Pulau Morotai',
12
-    'Kabupaten Pulau Taliabu',
13
-    'Kota Ternate',
14
-    'Kota Tidore Kepulauan'
15
-
16
-    // 10
17
-];
18
-
19
-exports.seedMalukuUtaraCities = async () => {
20
-    const province = await prisma.province.findFirst({
21
-        where: { name: 'Maluku Utara' },
22
-    });
23
-
24
-    if (!province) {
25
-        console.error('❌ Province Maluku Utara not found. Seed it first.');
26
-        return;
27
-    }
28
-
29
-    for (const name of cityNames) {
30
-        await prisma.city.upsert({
31
-            where: {
32
-                name_province_id: {
33
-                    name,
34
-                    province_id: province.id,
35
-                },
36
-            },
37
-            update: {
38
-                updatedAt: timeLocal.now().toDate()
39
-            },
40
-            create: {
41
-                name,
42
-                province_id: province.id,
43
-                createdAt: timeLocal.now().toDate()
44
-            },
45
-        });
46
-    }
47
-
48
-    console.log('✅ Maluku Utara City seeded!.');
49
-};

+ 97 - 0
prisma/seeders/city/MalukuUtaraCitySeeder.ts

@@ -0,0 +1,97 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Halmahera Barat',
6
+    'Kabupaten Halmahera Tengah',
7
+    'Kabupaten Halmahera Timur',
8
+    'Kabupaten Halmahera Selatan',
9
+    'Kabupaten Halmahera Utara',
10
+    'Kabupaten Kepulauan Sula',
11
+    'Kabupaten Pulau Morotai',
12
+    'Kabupaten Pulau Taliabu',
13
+    'Kota Ternate',
14
+    'Kota Tidore Kepulauan'
15
+];
16
+
17
+export async function seedMalukuUtaraCities(): Promise<void> {
18
+    const province = await prisma.province.findFirst({
19
+        where: { name: 'Maluku Utara' },
20
+    });
21
+
22
+    if (!province) {
23
+        console.error('❌ Province Maluku Utara not found. Seed it first.');
24
+        return;
25
+    }
26
+
27
+    for (const name of cityNames) {
28
+        await prisma.city.upsert({
29
+            where: {
30
+                name_province_id: {
31
+                    name,
32
+                    province_id: province.id,
33
+                },
34
+            },
35
+            update: {
36
+                updatedAt: now().toDate(),
37
+            },
38
+            create: {
39
+                name,
40
+                province_id: province.id,
41
+                createdAt: now().toDate(),
42
+            },
43
+        });
44
+    }
45
+
46
+    console.log('✅ Maluku Utara City seeded!');
47
+}
48
+
49
+// const prisma = require('../../../src/prisma/PrismaClient.js');
50
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
51
+
52
+// const cityNames = [
53
+//     'Kabupaten Halmahera Barat',
54
+//     'Kabupaten Halmahera Tengah',
55
+//     'Kabupaten Halmahera Timur',
56
+//     'Kabupaten Halmahera Selatan',
57
+//     'Kabupaten Halmahera Utara',
58
+//     'Kabupaten Kepulauan Sula',
59
+//     'Kabupaten Pulau Morotai',
60
+//     'Kabupaten Pulau Taliabu',
61
+//     'Kota Ternate',
62
+//     'Kota Tidore Kepulauan'
63
+
64
+//     // 10
65
+// ];
66
+
67
+// exports.seedMalukuUtaraCities = async () => {
68
+//     const province = await prisma.province.findFirst({
69
+//         where: { name: 'Maluku Utara' },
70
+//     });
71
+
72
+//     if (!province) {
73
+//         console.error('❌ Province Maluku Utara not found. Seed it first.');
74
+//         return;
75
+//     }
76
+
77
+//     for (const name of cityNames) {
78
+//         await prisma.city.upsert({
79
+//             where: {
80
+//                 name_province_id: {
81
+//                     name,
82
+//                     province_id: province.id,
83
+//                 },
84
+//             },
85
+//             update: {
86
+//                 updatedAt: timeLocal.now().toDate()
87
+//             },
88
+//             create: {
89
+//                 name,
90
+//                 province_id: province.id,
91
+//                 createdAt: timeLocal.now().toDate()
92
+//             },
93
+//         });
94
+//     }
95
+
96
+//     console.log('✅ Maluku Utara City seeded!.');
97
+// };

+ 0 - 49
prisma/seeders/city/NusaTenggaraBaratCitySeeder.js

@@ -1,49 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bima',
6
-    'Kabupaten Dompu',
7
-    'Kabupaten Lombok Barat',
8
-    'Kabupaten Lombok Tengah',
9
-    'Kabupaten Lombok Timur',
10
-    'Kabupaten Lombok Utara',
11
-    'Kabupaten Sumbawa',
12
-    'Kabupaten Sumbawa Barat',
13
-    'Kota Bima',
14
-    'Kota Mataram'
15
-
16
-    // 10
17
-];
18
-
19
-exports.seedNusaTenggaraBaratCities = async () => {
20
-    const province = await prisma.province.findFirst({
21
-        where: { name: 'Nusa Tenggara Barat' },
22
-    });
23
-
24
-    if (!province) {
25
-        console.error('❌ Province Nusa Tenggara Barat not found. Seed it first.');
26
-        return;
27
-    }
28
-
29
-    for (const name of cityNames) {
30
-        await prisma.city.upsert({
31
-            where: {
32
-                name_province_id: {
33
-                    name,
34
-                    province_id: province.id,
35
-                },
36
-            },
37
-            update: {
38
-                updatedAt: timeLocal.now().toDate()
39
-            },
40
-            create: {
41
-                name,
42
-                province_id: province.id,
43
-                createdAt: timeLocal.now().toDate()
44
-            },
45
-        });
46
-    }
47
-
48
-    console.log('✅ Nusa Tenggara Barat City seeded!.');
49
-};

+ 97 - 0
prisma/seeders/city/NusaTenggaraBaratCitySeeder.ts

@@ -0,0 +1,97 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bima',
6
+    'Kabupaten Dompu',
7
+    'Kabupaten Lombok Barat',
8
+    'Kabupaten Lombok Tengah',
9
+    'Kabupaten Lombok Timur',
10
+    'Kabupaten Lombok Utara',
11
+    'Kabupaten Sumbawa',
12
+    'Kabupaten Sumbawa Barat',
13
+    'Kota Bima',
14
+    'Kota Mataram'
15
+];
16
+
17
+export async function seedNusaTenggaraBaratCities(): Promise<void> {
18
+    const province = await prisma.province.findFirst({
19
+        where: { name: 'Nusa Tenggara Barat' },
20
+    });
21
+
22
+    if (!province) {
23
+        console.error('❌ Province Nusa Tenggara Barat not found. Seed it first.');
24
+        return;
25
+    }
26
+
27
+    for (const name of cityNames) {
28
+        await prisma.city.upsert({
29
+            where: {
30
+                name_province_id: {
31
+                    name,
32
+                    province_id: province.id,
33
+                },
34
+            },
35
+            update: {
36
+                updatedAt: now().toDate(),
37
+            },
38
+            create: {
39
+                name,
40
+                province_id: province.id,
41
+                createdAt: now().toDate(),
42
+            },
43
+        });
44
+    }
45
+
46
+    console.log('✅ Nusa Tenggara Barat City seeded!');
47
+}
48
+
49
+// const prisma = require('../../../src/prisma/PrismaClient.js');
50
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
51
+
52
+// const cityNames = [
53
+//     'Kabupaten Bima',
54
+//     'Kabupaten Dompu',
55
+//     'Kabupaten Lombok Barat',
56
+//     'Kabupaten Lombok Tengah',
57
+//     'Kabupaten Lombok Timur',
58
+//     'Kabupaten Lombok Utara',
59
+//     'Kabupaten Sumbawa',
60
+//     'Kabupaten Sumbawa Barat',
61
+//     'Kota Bima',
62
+//     'Kota Mataram'
63
+
64
+//     // 10
65
+// ];
66
+
67
+// exports.seedNusaTenggaraBaratCities = async () => {
68
+//     const province = await prisma.province.findFirst({
69
+//         where: { name: 'Nusa Tenggara Barat' },
70
+//     });
71
+
72
+//     if (!province) {
73
+//         console.error('❌ Province Nusa Tenggara Barat not found. Seed it first.');
74
+//         return;
75
+//     }
76
+
77
+//     for (const name of cityNames) {
78
+//         await prisma.city.upsert({
79
+//             where: {
80
+//                 name_province_id: {
81
+//                     name,
82
+//                     province_id: province.id,
83
+//                 },
84
+//             },
85
+//             update: {
86
+//                 updatedAt: timeLocal.now().toDate()
87
+//             },
88
+//             create: {
89
+//                 name,
90
+//                 province_id: province.id,
91
+//                 createdAt: timeLocal.now().toDate()
92
+//             },
93
+//         });
94
+//     }
95
+
96
+//     console.log('✅ Nusa Tenggara Barat City seeded!.');
97
+// };

+ 0 - 61
prisma/seeders/city/NusaTenggaraTimurCitySeeder.js

@@ -1,61 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Alor',
6
-    'Kabupaten Belu',
7
-    'Kabupaten Ende',
8
-    'Kabupaten Flores Timur',
9
-    'Kabupaten Kupang',
10
-    'Kabupaten Lembata',
11
-    'Kabupaten Malaka',
12
-    'Kabupaten Manggarai',
13
-    'Kabupaten Manggarai Barat',
14
-    'Kabupaten Manggarai Timur',
15
-    'Kabupaten Nagekeo',
16
-    'Kabupaten Ngada',
17
-    'Kabupaten Rote Ndao',
18
-    'Kabupaten Sabu Raijua',
19
-    'Kabupaten Sikka',
20
-    'Kabupaten Sumba Barat',
21
-    'Kabupaten Sumba Barat Daya',
22
-    'Kabupaten Sumba Tengah',
23
-    'Kabupaten Sumba Timur',
24
-    'Kabupaten Timor Tengah Selatan',
25
-    'Kabupaten Timor Tengah Utara',
26
-    'Kota Kupang'
27
-
28
-    // 22
29
-];
30
-
31
-exports.seedNusaTenggaraTimurCities = async () => {
32
-    const province = await prisma.province.findFirst({
33
-        where: { name: 'Nusa Tenggara Timur' },
34
-    });
35
-
36
-    if (!province) {
37
-        console.error('❌ Province Nusa Tenggara Timur not found. Seed it first.');
38
-        return;
39
-    }
40
-
41
-    for (const name of cityNames) {
42
-        await prisma.city.upsert({
43
-            where: {
44
-                name_province_id: {
45
-                    name,
46
-                    province_id: province.id,
47
-                },
48
-            },
49
-            update: {
50
-                updatedAt: timeLocal.now().toDate()
51
-            },
52
-            create: {
53
-                name,
54
-                province_id: province.id,
55
-                createdAt: timeLocal.now().toDate()
56
-            },
57
-        });
58
-    }
59
-
60
-    console.log('✅ Nusa Tenggara Timur City seeded!.');
61
-};

+ 121 - 0
prisma/seeders/city/NusaTenggaraTimurCitySeeder.ts

@@ -0,0 +1,121 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Alor',
6
+    'Kabupaten Belu',
7
+    'Kabupaten Ende',
8
+    'Kabupaten Flores Timur',
9
+    'Kabupaten Kupang',
10
+    'Kabupaten Lembata',
11
+    'Kabupaten Malaka',
12
+    'Kabupaten Manggarai',
13
+    'Kabupaten Manggarai Barat',
14
+    'Kabupaten Manggarai Timur',
15
+    'Kabupaten Nagekeo',
16
+    'Kabupaten Ngada',
17
+    'Kabupaten Rote Ndao',
18
+    'Kabupaten Sabu Raijua',
19
+    'Kabupaten Sikka',
20
+    'Kabupaten Sumba Barat',
21
+    'Kabupaten Sumba Barat Daya',
22
+    'Kabupaten Sumba Tengah',
23
+    'Kabupaten Sumba Timur',
24
+    'Kabupaten Timor Tengah Selatan',
25
+    'Kabupaten Timor Tengah Utara',
26
+    'Kota Kupang'
27
+];
28
+
29
+export async function seedNusaTenggaraTimurCities(): Promise<void> {
30
+    const province = await prisma.province.findFirst({
31
+        where: { name: 'Nusa Tenggara Timur' },
32
+    });
33
+
34
+    if (!province) {
35
+        console.error('❌ Province Nusa Tenggara Timur not found. Seed it first.');
36
+        return;
37
+    }
38
+
39
+    for (const name of cityNames) {
40
+        await prisma.city.upsert({
41
+            where: {
42
+                name_province_id: {
43
+                    name,
44
+                    province_id: province.id,
45
+                },
46
+            },
47
+            update: {
48
+                updatedAt: now().toDate(),
49
+            },
50
+            create: {
51
+                name,
52
+                province_id: province.id,
53
+                createdAt: now().toDate(),
54
+            },
55
+        });
56
+    }
57
+
58
+    console.log('✅ Nusa Tenggara Timur City seeded!');
59
+}
60
+
61
+// const prisma = require('../../../src/prisma/PrismaClient.js');
62
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
63
+
64
+// const cityNames = [
65
+//     'Kabupaten Alor',
66
+//     'Kabupaten Belu',
67
+//     'Kabupaten Ende',
68
+//     'Kabupaten Flores Timur',
69
+//     'Kabupaten Kupang',
70
+//     'Kabupaten Lembata',
71
+//     'Kabupaten Malaka',
72
+//     'Kabupaten Manggarai',
73
+//     'Kabupaten Manggarai Barat',
74
+//     'Kabupaten Manggarai Timur',
75
+//     'Kabupaten Nagekeo',
76
+//     'Kabupaten Ngada',
77
+//     'Kabupaten Rote Ndao',
78
+//     'Kabupaten Sabu Raijua',
79
+//     'Kabupaten Sikka',
80
+//     'Kabupaten Sumba Barat',
81
+//     'Kabupaten Sumba Barat Daya',
82
+//     'Kabupaten Sumba Tengah',
83
+//     'Kabupaten Sumba Timur',
84
+//     'Kabupaten Timor Tengah Selatan',
85
+//     'Kabupaten Timor Tengah Utara',
86
+//     'Kota Kupang'
87
+
88
+//     // 22
89
+// ];
90
+
91
+// exports.seedNusaTenggaraTimurCities = async () => {
92
+//     const province = await prisma.province.findFirst({
93
+//         where: { name: 'Nusa Tenggara Timur' },
94
+//     });
95
+
96
+//     if (!province) {
97
+//         console.error('❌ Province Nusa Tenggara Timur not found. Seed it first.');
98
+//         return;
99
+//     }
100
+
101
+//     for (const name of cityNames) {
102
+//         await prisma.city.upsert({
103
+//             where: {
104
+//                 name_province_id: {
105
+//                     name,
106
+//                     province_id: province.id,
107
+//                 },
108
+//             },
109
+//             update: {
110
+//                 updatedAt: timeLocal.now().toDate()
111
+//             },
112
+//             create: {
113
+//                 name,
114
+//                 province_id: province.id,
115
+//                 createdAt: timeLocal.now().toDate()
116
+//             },
117
+//         });
118
+//     }
119
+
120
+//     console.log('✅ Nusa Tenggara Timur City seeded!.');
121
+// };

+ 0 - 46
prisma/seeders/city/PapuaBaratCitySeeder.js

@@ -1,46 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Fakfak',
6
-    'Kabupaten Kaimana',
7
-    'Kabupaten Manokwari',
8
-    'Kabupaten Manokwari Selatan',
9
-    'Kabupaten Pegunungan Arfak',
10
-    'Kabupaten Teluk Bintuni',
11
-    'Kabupaten Teluk Wondama',
12
-
13
-    // 7
14
-];
15
-
16
-exports.seedPapuaBaratCities = async () => {
17
-    const province = await prisma.province.findFirst({
18
-        where: { name: 'Papua Barat' },
19
-    });
20
-
21
-    if (!province) {
22
-        console.error('❌ Province Papua Barat not found. Seed it first.');
23
-        return;
24
-    }
25
-
26
-    for (const name of cityNames) {
27
-        await prisma.city.upsert({
28
-            where: {
29
-                name_province_id: {
30
-                    name,
31
-                    province_id: province.id,
32
-                },
33
-            },
34
-            update: {
35
-                updatedAt: timeLocal.now().toDate()
36
-            },
37
-            create: {
38
-                name,
39
-                province_id: province.id,
40
-                createdAt: timeLocal.now().toDate()
41
-            },
42
-        });
43
-    }
44
-
45
-    console.log('✅ Papua Barat City seeded!.');
46
-};

+ 92 - 0
prisma/seeders/city/PapuaBaratCitySeeder.ts

@@ -0,0 +1,92 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Fakfak',
6
+    'Kabupaten Kaimana',
7
+    'Kabupaten Manokwari',
8
+    'Kabupaten Manokwari Selatan',
9
+    'Kabupaten Pegunungan Arfak',
10
+    'Kabupaten Teluk Bintuni',
11
+    'Kabupaten Teluk Wondama',
12
+];
13
+
14
+export const seedPapuaBaratCities = async (): Promise<void> => {
15
+    const province = await prisma.province.findFirst({
16
+        where: { name: 'Papua Barat' },
17
+    });
18
+
19
+    if (!province) {
20
+        console.error('❌ Province Papua Barat not found. Seed it first.');
21
+        return;
22
+    }
23
+
24
+    for (const name of cityNames) {
25
+        await prisma.city.upsert({
26
+            where: {
27
+                // Pastikan composite key ini sudah dibuat di schema.prisma
28
+                name_province_id: {
29
+                    name,
30
+                    province_id: province.id,
31
+                },
32
+            },
33
+            update: {
34
+                updatedAt: now().toDate(),
35
+            },
36
+            create: {
37
+                name,
38
+                province_id: province.id,
39
+                createdAt: now().toDate(),
40
+            },
41
+        });
42
+    }
43
+
44
+    console.log('✅ Papua Barat City seeded!.');
45
+};
46
+
47
+// const prisma = require('../../../src/prisma/PrismaClient.js');
48
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
49
+
50
+// const cityNames = [
51
+//     'Kabupaten Fakfak',
52
+//     'Kabupaten Kaimana',
53
+//     'Kabupaten Manokwari',
54
+//     'Kabupaten Manokwari Selatan',
55
+//     'Kabupaten Pegunungan Arfak',
56
+//     'Kabupaten Teluk Bintuni',
57
+//     'Kabupaten Teluk Wondama',
58
+
59
+//     // 7
60
+// ];
61
+
62
+// exports.seedPapuaBaratCities = async () => {
63
+//     const province = await prisma.province.findFirst({
64
+//         where: { name: 'Papua Barat' },
65
+//     });
66
+
67
+//     if (!province) {
68
+//         console.error('❌ Province Papua Barat not found. Seed it first.');
69
+//         return;
70
+//     }
71
+
72
+//     for (const name of cityNames) {
73
+//         await prisma.city.upsert({
74
+//             where: {
75
+//                 name_province_id: {
76
+//                     name,
77
+//                     province_id: province.id,
78
+//                 },
79
+//             },
80
+//             update: {
81
+//                 updatedAt: timeLocal.now().toDate()
82
+//             },
83
+//             create: {
84
+//                 name,
85
+//                 province_id: province.id,
86
+//                 createdAt: timeLocal.now().toDate()
87
+//             },
88
+//         });
89
+//     }
90
+
91
+//     console.log('✅ Papua Barat City seeded!.');
92
+// };

+ 0 - 45
prisma/seeders/city/PapuaBaratDayaCitySeeder.js

@@ -1,45 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Maybrat',
6
-    'Kabupaten Sorong',
7
-    'Kabupaten Sorong Selatan',
8
-    'Kabupaten Tambrauw',
9
-    'Kabupaten Raja Ampat',
10
-    'Kota Sorong'
11
-
12
-    // 6
13
-];
14
-
15
-exports.seedPapuaBaratDayaCities = async () => {
16
-    const province = await prisma.province.findFirst({
17
-        where: { name: 'Papua Barat Daya' },
18
-    });
19
-
20
-    if (!province) {
21
-        console.error('❌ Province Papua Barat Daya not found. Seed it first.');
22
-        return;
23
-    }
24
-
25
-    for (const name of cityNames) {
26
-        await prisma.city.upsert({
27
-            where: {
28
-                name_province_id: {
29
-                    name,
30
-                    province_id: province.id,
31
-                },
32
-            },
33
-            update: {
34
-                updatedAt: timeLocal.now().toDate()
35
-            },
36
-            create: {
37
-                name,
38
-                province_id: province.id,
39
-                createdAt: timeLocal.now().toDate()
40
-            },
41
-        });
42
-    }
43
-
44
-    console.log('✅ Papua Barat Daya City seeded!.');
45
-};

+ 90 - 0
prisma/seeders/city/PapuaBaratDayaCitySeeder.ts

@@ -0,0 +1,90 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Maybrat',
6
+    'Kabupaten Sorong',
7
+    'Kabupaten Sorong Selatan',
8
+    'Kabupaten Tambrauw',
9
+    'Kabupaten Raja Ampat',
10
+    'Kota Sorong',
11
+];
12
+
13
+export const seedPapuaBaratDayaCities = async (): Promise<void> => {
14
+    const province = await prisma.province.findFirst({
15
+        where: { name: 'Papua Barat Daya' },
16
+    });
17
+
18
+    if (!province) {
19
+        console.error('❌ Province Papua Barat Daya not found. Seed it first.');
20
+        return;
21
+    }
22
+
23
+    for (const name of cityNames) {
24
+        await prisma.city.upsert({
25
+            where: {
26
+                // Requires a unique constraint on [name, province_id] in your Prisma schema
27
+                name_province_id: {
28
+                    name,
29
+                    province_id: province.id,
30
+                },
31
+            },
32
+            update: {
33
+                updatedAt: now().toDate(),
34
+            },
35
+            create: {
36
+                name,
37
+                province_id: province.id,
38
+                createdAt: now().toDate(),
39
+            },
40
+        });
41
+    }
42
+
43
+    console.log('✅ Papua Barat Daya City seeded!.');
44
+};
45
+
46
+// const prisma = require('../../../src/prisma/PrismaClient.js');
47
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
48
+
49
+// const cityNames = [
50
+//     'Kabupaten Maybrat',
51
+//     'Kabupaten Sorong',
52
+//     'Kabupaten Sorong Selatan',
53
+//     'Kabupaten Tambrauw',
54
+//     'Kabupaten Raja Ampat',
55
+//     'Kota Sorong'
56
+
57
+//     // 6
58
+// ];
59
+
60
+// exports.seedPapuaBaratDayaCities = async () => {
61
+//     const province = await prisma.province.findFirst({
62
+//         where: { name: 'Papua Barat Daya' },
63
+//     });
64
+
65
+//     if (!province) {
66
+//         console.error('❌ Province Papua Barat Daya not found. Seed it first.');
67
+//         return;
68
+//     }
69
+
70
+//     for (const name of cityNames) {
71
+//         await prisma.city.upsert({
72
+//             where: {
73
+//                 name_province_id: {
74
+//                     name,
75
+//                     province_id: province.id,
76
+//                 },
77
+//             },
78
+//             update: {
79
+//                 updatedAt: timeLocal.now().toDate()
80
+//             },
81
+//             create: {
82
+//                 name,
83
+//                 province_id: province.id,
84
+//                 createdAt: timeLocal.now().toDate()
85
+//             },
86
+//         });
87
+//     }
88
+
89
+//     console.log('✅ Papua Barat Daya City seeded!.');
90
+// };

+ 0 - 46
prisma/seeders/city/PapuaCitySeeder.js

@@ -1,46 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Biak Numfor',
6
-    'Kabupaten Jayapura',
7
-    'Kabupaten Keerom',
8
-    'Kabupaten Kepulauan Yapen',
9
-    'Kabupaten Mamberamo Raya',
10
-    'Kabupaten Sarmi',
11
-    'Kabupaten Supiori',
12
-    'Kabupaten Waropen',
13
-    'Kota Jayapura'
14
-
15
-    // 9
16
-];
17
-
18
-exports.seedPapuaCities = async () => {
19
-    const province = await prisma.province.findFirst({
20
-        where: { name: 'Papua' },
21
-    });
22
-
23
-    if (!province) {
24
-        console.error('❌ Province Papua not found. Seed it first.');
25
-        return;
26
-    }
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: { updatedAt: timeLocal.now().toDate() },
37
-            create: {
38
-                name,
39
-                province_id: province.id,
40
-                createdAt: timeLocal.now().toDate()
41
-            },
42
-        });
43
-    }
44
-
45
-    console.log('✅ Papua City seeded!.');
46
-};

+ 93 - 0
prisma/seeders/city/PapuaCitySeeder.ts

@@ -0,0 +1,93 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Biak Numfor',
6
+    'Kabupaten Jayapura',
7
+    'Kabupaten Keerom',
8
+    'Kabupaten Kepulauan Yapen',
9
+    'Kabupaten Mamberamo Raya',
10
+    'Kabupaten Sarmi',
11
+    'Kabupaten Supiori',
12
+    'Kabupaten Waropen',
13
+    'Kota Jayapura'
14
+];
15
+
16
+export async function seedPapuaCities(): Promise<void> {
17
+    const province = await prisma.province.findFirst({
18
+        where: { name: 'Papua' },
19
+    });
20
+
21
+    if (!province) {
22
+        console.error('❌ Province Papua not found. Seed it first.');
23
+        return;
24
+    }
25
+
26
+    for (const name of cityNames) {
27
+        await prisma.city.upsert({
28
+            where: {
29
+                name_province_id: {
30
+                    name,
31
+                    province_id: province.id,
32
+                },
33
+            },
34
+            update: {
35
+                updatedAt: now().toDate(),
36
+            },
37
+            create: {
38
+                name,
39
+                province_id: province.id,
40
+                createdAt: now().toDate(),
41
+            },
42
+        });
43
+    }
44
+
45
+    console.log('✅ Papua City seeded!');
46
+}
47
+
48
+// const prisma = require('../../../src/prisma/PrismaClient.js');
49
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
50
+
51
+// const cityNames = [
52
+//     'Kabupaten Biak Numfor',
53
+//     'Kabupaten Jayapura',
54
+//     'Kabupaten Keerom',
55
+//     'Kabupaten Kepulauan Yapen',
56
+//     'Kabupaten Mamberamo Raya',
57
+//     'Kabupaten Sarmi',
58
+//     'Kabupaten Supiori',
59
+//     'Kabupaten Waropen',
60
+//     'Kota Jayapura'
61
+
62
+//     // 9
63
+// ];
64
+
65
+// exports.seedPapuaCities = async () => {
66
+//     const province = await prisma.province.findFirst({
67
+//         where: { name: 'Papua' },
68
+//     });
69
+
70
+//     if (!province) {
71
+//         console.error('❌ Province Papua not found. Seed it first.');
72
+//         return;
73
+//     }
74
+
75
+//     for (const name of cityNames) {
76
+//         await prisma.city.upsert({
77
+//             where: {
78
+//                 name_province_id: {
79
+//                     name,
80
+//                     province_id: province.id,
81
+//                 },
82
+//             },
83
+//             update: { updatedAt: timeLocal.now().toDate() },
84
+//             create: {
85
+//                 name,
86
+//                 province_id: province.id,
87
+//                 createdAt: timeLocal.now().toDate()
88
+//             },
89
+//         });
90
+//     }
91
+
92
+//     console.log('✅ Papua City seeded!.');
93
+// };

+ 0 - 45
prisma/seeders/city/PapuaPegununganCitySeeder.js

@@ -1,45 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Jayawijaya',
6
-    'Kabupaten Lanny Jaya',
7
-    'Kabupaten Mamberamo Tengah',
8
-    'Kabupaten Nduga',
9
-    'Kabupaten Pegunungan Bintang',
10
-    'Kabupaten Tolikara',
11
-    'Kabupaten Yahukimo',
12
-    'Kabupaten Yalimo'
13
-
14
-    // 8
15
-];
16
-
17
-exports.seedPapuaPegununganCities = async () => {
18
-    const province = await prisma.province.findFirst({
19
-        where: { name: 'Papua Pegunungan' },
20
-    });
21
-
22
-    if (!province) {
23
-        console.error('❌ Province Papua Pegunungan not found. Seed it first.');
24
-        return;
25
-    }
26
-
27
-    for (const name of cityNames) {
28
-        await prisma.city.upsert({
29
-            where: {
30
-                name_province_id: {
31
-                    name,
32
-                    province_id: province.id,
33
-                },
34
-            },
35
-            update: { updatedAt: timeLocal.now().toDate() },
36
-            create: {
37
-                name,
38
-                province_id: province.id,
39
-                createdAt: timeLocal.now().toDate()
40
-            },
41
-        });
42
-    }
43
-
44
-    console.log('✅ Papua Pegunungan City seeded!.');
45
-};

+ 92 - 0
prisma/seeders/city/PapuaPegununganCitySeeder.ts

@@ -0,0 +1,92 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Jayawijaya',
6
+    'Kabupaten Lanny Jaya',
7
+    'Kabupaten Mamberamo Tengah',
8
+    'Kabupaten Nduga',
9
+    'Kabupaten Pegunungan Bintang',
10
+    'Kabupaten Tolikara',
11
+    'Kabupaten Yahukimo',
12
+    'Kabupaten Yalimo',
13
+];
14
+
15
+export const seedPapuaPegununganCities = async (): Promise<void> => {
16
+    const province = await prisma.province.findFirst({
17
+        where: { name: 'Papua Pegunungan' },
18
+    });
19
+
20
+    if (!province) {
21
+        console.error('❌ Province Papua Pegunungan not found. Seed it first.');
22
+        return;
23
+    }
24
+
25
+    for (const name of cityNames) {
26
+        await prisma.city.upsert({
27
+            where: {
28
+                // Pastikan ada composite unique constraint [name, province_id] di schema.prisma
29
+                name_province_id: {
30
+                    name,
31
+                    province_id: province.id,
32
+                },
33
+            },
34
+            update: {
35
+                updatedAt: now().toDate(),
36
+            },
37
+            create: {
38
+                name,
39
+                province_id: province.id,
40
+                createdAt: now().toDate(),
41
+            },
42
+        });
43
+    }
44
+
45
+    console.log('✅ Papua Pegunungan City seeded!.');
46
+};
47
+
48
+// const prisma = require('../../../src/prisma/PrismaClient.js');
49
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
50
+
51
+// const cityNames = [
52
+//     'Kabupaten Jayawijaya',
53
+//     'Kabupaten Lanny Jaya',
54
+//     'Kabupaten Mamberamo Tengah',
55
+//     'Kabupaten Nduga',
56
+//     'Kabupaten Pegunungan Bintang',
57
+//     'Kabupaten Tolikara',
58
+//     'Kabupaten Yahukimo',
59
+//     'Kabupaten Yalimo'
60
+
61
+//     // 8
62
+// ];
63
+
64
+// exports.seedPapuaPegununganCities = async () => {
65
+//     const province = await prisma.province.findFirst({
66
+//         where: { name: 'Papua Pegunungan' },
67
+//     });
68
+
69
+//     if (!province) {
70
+//         console.error('❌ Province Papua Pegunungan not found. Seed it first.');
71
+//         return;
72
+//     }
73
+
74
+//     for (const name of cityNames) {
75
+//         await prisma.city.upsert({
76
+//             where: {
77
+//                 name_province_id: {
78
+//                     name,
79
+//                     province_id: province.id,
80
+//                 },
81
+//             },
82
+//             update: { updatedAt: timeLocal.now().toDate() },
83
+//             create: {
84
+//                 name,
85
+//                 province_id: province.id,
86
+//                 createdAt: timeLocal.now().toDate()
87
+//             },
88
+//         });
89
+//     }
90
+
91
+//     console.log('✅ Papua Pegunungan City seeded!.');
92
+// };

+ 0 - 41
prisma/seeders/city/PapuaSelatanCitySeeder.js

@@ -1,41 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Asmat',
6
-    'Kabupaten Boven Digoel',
7
-    'Kabupaten Mappi',
8
-    'Kabupaten Merauke'
9
-
10
-    // 4
11
-];
12
-
13
-exports.seedPapuaSelatanCities = async () => {
14
-    const province = await prisma.province.findFirst({
15
-        where: { name: 'Papua Selatan' },
16
-    });
17
-
18
-    if (!province) {
19
-        console.error('❌ Province Papua Selatan not found. Seed it first.');
20
-        return;
21
-    }
22
-
23
-    for (const name of cityNames) {
24
-        await prisma.city.upsert({
25
-            where: {
26
-                name_province_id: {
27
-                    name,
28
-                    province_id: province.id,
29
-                },
30
-            },
31
-            update: { updatedAt: timeLocal.now().toDate() },
32
-            create: {
33
-                name,
34
-                province_id: province.id,
35
-                createdAt: timeLocal.now().toDate()
36
-            },
37
-        });
38
-    }
39
-
40
-    console.log('✅ Papua Selatan City seeded!.');
41
-};

+ 84 - 0
prisma/seeders/city/PapuaSelatanCitySeeder.ts

@@ -0,0 +1,84 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Asmat',
6
+    'Kabupaten Boven Digoel',
7
+    'Kabupaten Mappi',
8
+    'Kabupaten Merauke'
9
+];
10
+
11
+export const seedPapuaSelatanCities = async (): Promise<void> => {
12
+    const province = await prisma.province.findFirst({
13
+        where: { name: 'Papua Selatan' },
14
+    });
15
+
16
+    if (!province) {
17
+        console.error('❌ Province Papua Selatan not found. Seed it first.');
18
+        return;
19
+    }
20
+
21
+    for (const name of cityNames) {
22
+        await prisma.city.upsert({
23
+            where: {
24
+                name_province_id: {
25
+                    name,
26
+                    province_id: province.id,
27
+                },
28
+            },
29
+            update: {
30
+                updatedAt: now().toDate(),
31
+            },
32
+            create: {
33
+                name,
34
+                province_id: province.id,
35
+                createdAt: now().toDate(),
36
+            },
37
+        });
38
+    }
39
+
40
+    console.log('✅ Papua Selatan City seeded!.');
41
+};
42
+
43
+
44
+// const prisma = require('../../../src/prisma/PrismaClient.js');
45
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
46
+
47
+// const cityNames = [
48
+//     'Kabupaten Asmat',
49
+//     'Kabupaten Boven Digoel',
50
+//     'Kabupaten Mappi',
51
+//     'Kabupaten Merauke'
52
+
53
+//     // 4
54
+// ];
55
+
56
+// exports.seedPapuaSelatanCities = async () => {
57
+//     const province = await prisma.province.findFirst({
58
+//         where: { name: 'Papua Selatan' },
59
+//     });
60
+
61
+//     if (!province) {
62
+//         console.error('❌ Province Papua Selatan not found. Seed it first.');
63
+//         return;
64
+//     }
65
+
66
+//     for (const name of cityNames) {
67
+//         await prisma.city.upsert({
68
+//             where: {
69
+//                 name_province_id: {
70
+//                     name,
71
+//                     province_id: province.id,
72
+//                 },
73
+//             },
74
+//             update: { updatedAt: timeLocal.now().toDate() },
75
+//             create: {
76
+//                 name,
77
+//                 province_id: province.id,
78
+//                 createdAt: timeLocal.now().toDate()
79
+//             },
80
+//         });
81
+//     }
82
+
83
+//     console.log('✅ Papua Selatan City seeded!.');
84
+// };

+ 0 - 45
prisma/seeders/city/PapuaTengahCitySeeder.js

@@ -1,45 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Deiyai',
6
-    'Kabupaten Dogiyai',
7
-    'Kabupaten Intan Jaya',
8
-    'Kabupaten Mimika',
9
-    'Kabupaten Nabire',
10
-    'Kabupaten Paniai',
11
-    'Kabupaten Puncak',
12
-    'Kabupaten Puncak Jaya'
13
-
14
-    // 8
15
-];
16
-
17
-exports.seedPapuaTengahCities = async () => {
18
-    const province = await prisma.province.findFirst({
19
-        where: { name: 'Papua Tengah' },
20
-    });
21
-
22
-    if (!province) {
23
-        console.error('❌ Province Papua Tengah not found. Seed it first.');
24
-        return;
25
-    }
26
-
27
-    for (const name of cityNames) {
28
-        await prisma.city.upsert({
29
-            where: {
30
-                name_province_id: {
31
-                    name,
32
-                    province_id: province.id,
33
-                },
34
-            },
35
-            update: { updatedAt: timeLocal.now().toDate() },
36
-            create: {
37
-                name,
38
-                province_id: province.id,
39
-                createdAt: timeLocal.now().toDate()
40
-            },
41
-        });
42
-    }
43
-
44
-    console.log('✅ Papua Tengah City seeded!.');
45
-};

+ 92 - 0
prisma/seeders/city/PapuaTengahCitySeeder.ts

@@ -0,0 +1,92 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Deiyai',
6
+    'Kabupaten Dogiyai',
7
+    'Kabupaten Intan Jaya',
8
+    'Kabupaten Mimika',
9
+    'Kabupaten Nabire',
10
+    'Kabupaten Paniai',
11
+    'Kabupaten Puncak',
12
+    'Kabupaten Puncak Jaya',
13
+];
14
+
15
+export const seedPapuaTengahCities = async (): Promise<void> => {
16
+    const province = await prisma.province.findFirst({
17
+        where: { name: 'Papua Tengah' },
18
+    });
19
+
20
+    if (!province) {
21
+        console.error('❌ Province Papua Tengah not found. Seed it first.');
22
+        return;
23
+    }
24
+
25
+    for (const name of cityNames) {
26
+        await prisma.city.upsert({
27
+            where: {
28
+                name_province_id: {
29
+                    name,
30
+                    province_id: province.id,
31
+                },
32
+            },
33
+            update: {
34
+                updatedAt: now().toDate(),
35
+            },
36
+            create: {
37
+                name,
38
+                province_id: province.id,
39
+                createdAt: now().toDate(),
40
+            },
41
+        });
42
+    }
43
+
44
+    console.log('✅ Papua Tengah City seeded!.');
45
+};
46
+
47
+
48
+// const prisma = require('../../../src/prisma/PrismaClient.js');
49
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
50
+
51
+// const cityNames = [
52
+//     'Kabupaten Deiyai',
53
+//     'Kabupaten Dogiyai',
54
+//     'Kabupaten Intan Jaya',
55
+//     'Kabupaten Mimika',
56
+//     'Kabupaten Nabire',
57
+//     'Kabupaten Paniai',
58
+//     'Kabupaten Puncak',
59
+//     'Kabupaten Puncak Jaya'
60
+
61
+//     // 8
62
+// ];
63
+
64
+// exports.seedPapuaTengahCities = async () => {
65
+//     const province = await prisma.province.findFirst({
66
+//         where: { name: 'Papua Tengah' },
67
+//     });
68
+
69
+//     if (!province) {
70
+//         console.error('❌ Province Papua Tengah not found. Seed it first.');
71
+//         return;
72
+//     }
73
+
74
+//     for (const name of cityNames) {
75
+//         await prisma.city.upsert({
76
+//             where: {
77
+//                 name_province_id: {
78
+//                     name,
79
+//                     province_id: province.id,
80
+//                 },
81
+//             },
82
+//             update: { updatedAt: timeLocal.now().toDate() },
83
+//             create: {
84
+//                 name,
85
+//                 province_id: province.id,
86
+//                 createdAt: timeLocal.now().toDate()
87
+//             },
88
+//         });
89
+//     }
90
+
91
+//     console.log('✅ Papua Tengah City seeded!.');
92
+// };

+ 0 - 49
prisma/seeders/city/RiauCitySeeder.js

@@ -1,49 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bengkalis',
6
-    'Kabupaten Indragiri Hilir',
7
-    'Kabupaten Indragiri Hulu',
8
-    'Kabupaten Kampar',
9
-    'Kabupaten Kepulauan Meranti',
10
-    'Kabupaten Kuantan Singingi',
11
-    'Kabupaten Pelalawan',
12
-    'Kabupaten Rokan Hilir',
13
-    'Kabupaten Rokan Hulu',
14
-    'Kabupaten Siak',
15
-    'Kota Dumai',
16
-    'Kota Pekanbaru'
17
-
18
-    // 12
19
-];
20
-
21
-exports.seedRiauCities = async () => {
22
-    const province = await prisma.province.findFirst({
23
-        where: { name: 'Riau' },
24
-    });
25
-
26
-    if (!province) {
27
-        console.error('❌ Province Riau not found. Seed it first.');
28
-        return;
29
-    }
30
-
31
-    for (const name of cityNames) {
32
-        await prisma.city.upsert({
33
-            where: {
34
-                name_province_id: {
35
-                    name,
36
-                    province_id: province.id,
37
-                },
38
-            },
39
-            update: { updatedAt: timeLocal.now().toDate() },
40
-            create: {
41
-                name,
42
-                province_id: province.id,
43
-                createdAt: timeLocal.now().toDate()
44
-            },
45
-        });
46
-    }
47
-
48
-    console.log('✅ Riau City seeded!.');
49
-};

+ 100 - 0
prisma/seeders/city/RiauCitySeeder.ts

@@ -0,0 +1,100 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bengkalis',
6
+    'Kabupaten Indragiri Hilir',
7
+    'Kabupaten Indragiri Hulu',
8
+    'Kabupaten Kampar',
9
+    'Kabupaten Kepulauan Meranti',
10
+    'Kabupaten Kuantan Singingi',
11
+    'Kabupaten Pelalawan',
12
+    'Kabupaten Rokan Hilir',
13
+    'Kabupaten Rokan Hulu',
14
+    'Kabupaten Siak',
15
+    'Kota Dumai',
16
+    'Kota Pekanbaru'
17
+];
18
+
19
+export const seedRiauCities = async (): Promise<void> => {
20
+    const province = await prisma.province.findFirst({
21
+        where: { name: 'Riau' },
22
+    });
23
+
24
+    if (!province) {
25
+        console.error('❌ Province Riau not found. Seed it first.');
26
+        return;
27
+    }
28
+
29
+    for (const name of cityNames) {
30
+        await prisma.city.upsert({
31
+            where: {
32
+                // Pastikan kamu sudah buat @@unique([name, province_id]) di model City pada schema.prisma
33
+                name_province_id: {
34
+                    name,
35
+                    province_id: province.id,
36
+                },
37
+            },
38
+            update: {
39
+                updatedAt: now().toDate(),
40
+            },
41
+            create: {
42
+                name,
43
+                province_id: province.id,
44
+                createdAt: now().toDate(),
45
+            },
46
+        });
47
+    }
48
+
49
+    console.log('✅ Riau City seeded!.');
50
+};
51
+
52
+// const prisma = require('../../../src/prisma/PrismaClient.js');
53
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
54
+
55
+// const cityNames = [
56
+//     'Kabupaten Bengkalis',
57
+//     'Kabupaten Indragiri Hilir',
58
+//     'Kabupaten Indragiri Hulu',
59
+//     'Kabupaten Kampar',
60
+//     'Kabupaten Kepulauan Meranti',
61
+//     'Kabupaten Kuantan Singingi',
62
+//     'Kabupaten Pelalawan',
63
+//     'Kabupaten Rokan Hilir',
64
+//     'Kabupaten Rokan Hulu',
65
+//     'Kabupaten Siak',
66
+//     'Kota Dumai',
67
+//     'Kota Pekanbaru'
68
+
69
+//     // 12
70
+// ];
71
+
72
+// exports.seedRiauCities = async () => {
73
+//     const province = await prisma.province.findFirst({
74
+//         where: { name: 'Riau' },
75
+//     });
76
+
77
+//     if (!province) {
78
+//         console.error('❌ Province Riau not found. Seed it first.');
79
+//         return;
80
+//     }
81
+
82
+//     for (const name of cityNames) {
83
+//         await prisma.city.upsert({
84
+//             where: {
85
+//                 name_province_id: {
86
+//                     name,
87
+//                     province_id: province.id,
88
+//                 },
89
+//             },
90
+//             update: { updatedAt: timeLocal.now().toDate() },
91
+//             create: {
92
+//                 name,
93
+//                 province_id: province.id,
94
+//                 createdAt: timeLocal.now().toDate()
95
+//             },
96
+//         });
97
+//     }
98
+
99
+//     console.log('✅ Riau City seeded!.');
100
+// };

+ 0 - 43
prisma/seeders/city/SulawesiBaratCitySeeder.js

@@ -1,43 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Majene',
6
-    'Kabupaten Mamasa',
7
-    'Kabupaten Mamuju',
8
-    'Kabupaten Mamuju Tengah',
9
-    'Kabupaten Pasangkayu',
10
-    'Kabupaten Polewali Mandar'
11
-
12
-    // 6
13
-];
14
-
15
-exports.seedSulawesiBaratCities = async () => {
16
-    const province = await prisma.province.findFirst({
17
-        where: { name: 'Sulawesi Barat' },
18
-    });
19
-
20
-    if (!province) {
21
-        console.error('❌ Province Sulawesi Barat not found. Seed it first.');
22
-        return;
23
-    }
24
-
25
-    for (const name of cityNames) {
26
-        await prisma.city.upsert({
27
-            where: {
28
-                name_province_id: {
29
-                    name,
30
-                    province_id: province.id,
31
-                },
32
-            },
33
-            update: { updatedAt: timeLocal.now().toDate() },
34
-            create: {
35
-                name,
36
-                province_id: province.id,
37
-                createdAt: timeLocal.now().toDate()
38
-            },
39
-        });
40
-    }
41
-
42
-    console.log('✅ Sulawesi Barat City seeded!.');
43
-};

+ 88 - 0
prisma/seeders/city/SulawesiBaratCitySeeder.ts

@@ -0,0 +1,88 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Majene',
6
+    'Kabupaten Mamasa',
7
+    'Kabupaten Mamuju',
8
+    'Kabupaten Mamuju Tengah',
9
+    'Kabupaten Pasangkayu',
10
+    'Kabupaten Polewali Mandar'
11
+];
12
+
13
+export const seedSulawesiBaratCities = async (): Promise<void> => {
14
+    const province = await prisma.province.findFirst({
15
+        where: { name: 'Sulawesi Barat' },
16
+    });
17
+
18
+    if (!province) {
19
+        console.error('❌ Province Sulawesi Barat not found. Seed it first.');
20
+        return;
21
+    }
22
+
23
+    for (const name of cityNames) {
24
+        await prisma.city.upsert({
25
+            where: {
26
+                // Pastikan ada @@unique([name, province_id]) di model City di schema.prisma
27
+                name_province_id: {
28
+                    name,
29
+                    province_id: province.id,
30
+                },
31
+            },
32
+            update: {
33
+                updatedAt: now().toDate(),
34
+            },
35
+            create: {
36
+                name,
37
+                province_id: province.id,
38
+                createdAt: now().toDate(),
39
+            },
40
+        });
41
+    }
42
+
43
+    console.log('✅ Sulawesi Barat City seeded!.');
44
+};
45
+
46
+// const prisma = require('../../../src/prisma/PrismaClient.js');
47
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
48
+
49
+// const cityNames = [
50
+//     'Kabupaten Majene',
51
+//     'Kabupaten Mamasa',
52
+//     'Kabupaten Mamuju',
53
+//     'Kabupaten Mamuju Tengah',
54
+//     'Kabupaten Pasangkayu',
55
+//     'Kabupaten Polewali Mandar'
56
+
57
+//     // 6
58
+// ];
59
+
60
+// exports.seedSulawesiBaratCities = async () => {
61
+//     const province = await prisma.province.findFirst({
62
+//         where: { name: 'Sulawesi Barat' },
63
+//     });
64
+
65
+//     if (!province) {
66
+//         console.error('❌ Province Sulawesi Barat not found. Seed it first.');
67
+//         return;
68
+//     }
69
+
70
+//     for (const name of cityNames) {
71
+//         await prisma.city.upsert({
72
+//             where: {
73
+//                 name_province_id: {
74
+//                     name,
75
+//                     province_id: province.id,
76
+//                 },
77
+//             },
78
+//             update: { updatedAt: timeLocal.now().toDate() },
79
+//             create: {
80
+//                 name,
81
+//                 province_id: province.id,
82
+//                 createdAt: timeLocal.now().toDate()
83
+//             },
84
+//         });
85
+//     }
86
+
87
+//     console.log('✅ Sulawesi Barat City seeded!.');
88
+// };

+ 0 - 61
prisma/seeders/city/SulawesiSelatanCitySeeder.js

@@ -1,61 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bantaeng',
6
-    'Kabupaten Barru',
7
-    'Kabupaten Bone',
8
-    'Kabupaten Bulukumba',
9
-    'Kabupaten Enrekang',
10
-    'Kabupaten Gowa',
11
-    'Kabupaten Jeneponto',
12
-    'Kabupaten Kepulauan Selayar',
13
-    'Kabupaten Luwu',
14
-    'Kabupaten Luwu Timur',
15
-    'Kabupaten Luwu Utara',
16
-    'Kabupaten Maros',
17
-    'Kabupaten Pangkajene dan Kepulauan',
18
-    'Kabupaten Pinrang',
19
-    'Kabupaten Sidenreng Rappang',
20
-    'Kabupaten Sinjai',
21
-    'Kabupaten Soppeng',
22
-    'Kabupaten Takalar',
23
-    'Kabupaten Tana Toraja',
24
-    'Kabupaten Toraja Utara',
25
-    'Kabupaten Wajo',
26
-    'Kota Makassar',
27
-    'Kota Palopo',
28
-    'Kota Parepare'
29
-
30
-    // 24
31
-];
32
-
33
-exports.seedSulawesiSelatanCities = async () => {
34
-    const province = await prisma.province.findFirst({
35
-        where: { name: 'Sulawesi Selatan' },
36
-    });
37
-
38
-    if (!province) {
39
-        console.error('❌ Province Sulawesi Selatan not found. Seed it first.');
40
-        return;
41
-    }
42
-
43
-    for (const name of cityNames) {
44
-        await prisma.city.upsert({
45
-            where: {
46
-                name_province_id: {
47
-                    name,
48
-                    province_id: province.id,
49
-                },
50
-            },
51
-            update: { updatedAt: timeLocal.now().toDate() },
52
-            create: {
53
-                name,
54
-                province_id: province.id,
55
-                createdAt: timeLocal.now().toDate()
56
-            },
57
-        });
58
-    }
59
-
60
-    console.log('✅ Sulawesi Selatan City seeded!.');
61
-};

+ 124 - 0
prisma/seeders/city/SulawesiSelatanCitySeeder.ts

@@ -0,0 +1,124 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bantaeng',
6
+    'Kabupaten Barru',
7
+    'Kabupaten Bone',
8
+    'Kabupaten Bulukumba',
9
+    'Kabupaten Enrekang',
10
+    'Kabupaten Gowa',
11
+    'Kabupaten Jeneponto',
12
+    'Kabupaten Kepulauan Selayar',
13
+    'Kabupaten Luwu',
14
+    'Kabupaten Luwu Timur',
15
+    'Kabupaten Luwu Utara',
16
+    'Kabupaten Maros',
17
+    'Kabupaten Pangkajene dan Kepulauan',
18
+    'Kabupaten Pinrang',
19
+    'Kabupaten Sidenreng Rappang',
20
+    'Kabupaten Sinjai',
21
+    'Kabupaten Soppeng',
22
+    'Kabupaten Takalar',
23
+    'Kabupaten Tana Toraja',
24
+    'Kabupaten Toraja Utara',
25
+    'Kabupaten Wajo',
26
+    'Kota Makassar',
27
+    'Kota Palopo',
28
+    'Kota Parepare'
29
+];
30
+
31
+export const seedSulawesiSelatanCities = async (): Promise<void> => {
32
+    const province = await prisma.province.findFirst({
33
+        where: { name: 'Sulawesi Selatan' },
34
+    });
35
+
36
+    if (!province) {
37
+        console.error('❌ Province Sulawesi Selatan not found. Seed it first.');
38
+        return;
39
+    }
40
+
41
+    for (const name of cityNames) {
42
+        await prisma.city.upsert({
43
+            where: {
44
+                // Pastikan kombinasi ini unik di model City: @@unique([name, province_id], name: "name_province_id")
45
+                name_province_id: {
46
+                    name,
47
+                    province_id: province.id,
48
+                },
49
+            },
50
+            update: {
51
+                updatedAt: now().toDate(),
52
+            },
53
+            create: {
54
+                name,
55
+                province_id: province.id,
56
+                createdAt: now().toDate(),
57
+            },
58
+        });
59
+    }
60
+
61
+    console.log('✅ Sulawesi Selatan City seeded!.');
62
+};
63
+
64
+// const prisma = require('../../../src/prisma/PrismaClient.js');
65
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
66
+
67
+// const cityNames = [
68
+//     'Kabupaten Bantaeng',
69
+//     'Kabupaten Barru',
70
+//     'Kabupaten Bone',
71
+//     'Kabupaten Bulukumba',
72
+//     'Kabupaten Enrekang',
73
+//     'Kabupaten Gowa',
74
+//     'Kabupaten Jeneponto',
75
+//     'Kabupaten Kepulauan Selayar',
76
+//     'Kabupaten Luwu',
77
+//     'Kabupaten Luwu Timur',
78
+//     'Kabupaten Luwu Utara',
79
+//     'Kabupaten Maros',
80
+//     'Kabupaten Pangkajene dan Kepulauan',
81
+//     'Kabupaten Pinrang',
82
+//     'Kabupaten Sidenreng Rappang',
83
+//     'Kabupaten Sinjai',
84
+//     'Kabupaten Soppeng',
85
+//     'Kabupaten Takalar',
86
+//     'Kabupaten Tana Toraja',
87
+//     'Kabupaten Toraja Utara',
88
+//     'Kabupaten Wajo',
89
+//     'Kota Makassar',
90
+//     'Kota Palopo',
91
+//     'Kota Parepare'
92
+
93
+//     // 24
94
+// ];
95
+
96
+// exports.seedSulawesiSelatanCities = async () => {
97
+//     const province = await prisma.province.findFirst({
98
+//         where: { name: 'Sulawesi Selatan' },
99
+//     });
100
+
101
+//     if (!province) {
102
+//         console.error('❌ Province Sulawesi Selatan not found. Seed it first.');
103
+//         return;
104
+//     }
105
+
106
+//     for (const name of cityNames) {
107
+//         await prisma.city.upsert({
108
+//             where: {
109
+//                 name_province_id: {
110
+//                     name,
111
+//                     province_id: province.id,
112
+//                 },
113
+//             },
114
+//             update: { updatedAt: timeLocal.now().toDate() },
115
+//             create: {
116
+//                 name,
117
+//                 province_id: province.id,
118
+//                 createdAt: timeLocal.now().toDate()
119
+//             },
120
+//         });
121
+//     }
122
+
123
+//     console.log('✅ Sulawesi Selatan City seeded!.');
124
+// };

+ 0 - 50
prisma/seeders/city/SulawesiTengahCitySeeder.js

@@ -1,50 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Banggai',
6
-    'Kabupaten Banggai Kepulauan',
7
-    'Kabupaten Banggai Laut',
8
-    'Kabupaten Buol',
9
-    'Kabupaten Donggala',
10
-    'Kabupaten Morowali',
11
-    'Kabupaten Morowali Utara',
12
-    'Kabupaten Parigi Moutong',
13
-    'Kabupaten Poso',
14
-    'Kabupaten Sigi',
15
-    'Kabupaten Tojo Una-Una',
16
-    'Kabupaten Tolitoli',
17
-    'Kota Palu'
18
-
19
-    // 13
20
-];
21
-
22
-exports.seedSulawesiTengahCities = async () => {
23
-    const province = await prisma.province.findFirst({
24
-        where: { name: 'Sulawesi Tengah' },
25
-    });
26
-
27
-    if (!province) {
28
-        console.error('❌ Province Sulawesi Tengah not found. Seed it first.');
29
-        return;
30
-    }
31
-
32
-    for (const name of cityNames) {
33
-        await prisma.city.upsert({
34
-            where: {
35
-                name_province_id: {
36
-                    name,
37
-                    province_id: province.id,
38
-                },
39
-            },
40
-            update: { updatedAt: timeLocal.now().toDate() },
41
-            create: {
42
-                name,
43
-                province_id: province.id,
44
-                createdAt: timeLocal.now().toDate()
45
-            },
46
-        });
47
-    }
48
-
49
-    console.log('✅ Sulawesi Tengah City seeded!.');
50
-};

+ 102 - 0
prisma/seeders/city/SulawesiTengahCitySeeder.ts

@@ -0,0 +1,102 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Banggai',
6
+    'Kabupaten Banggai Kepulauan',
7
+    'Kabupaten Banggai Laut',
8
+    'Kabupaten Buol',
9
+    'Kabupaten Donggala',
10
+    'Kabupaten Morowali',
11
+    'Kabupaten Morowali Utara',
12
+    'Kabupaten Parigi Moutong',
13
+    'Kabupaten Poso',
14
+    'Kabupaten Sigi',
15
+    'Kabupaten Tojo Una-Una',
16
+    'Kabupaten Tolitoli',
17
+    'Kota Palu'
18
+];
19
+
20
+export const seedSulawesiTengahCities = async (): Promise<void> => {
21
+    const province = await prisma.province.findFirst({
22
+        where: { name: 'Sulawesi Tengah' },
23
+    });
24
+
25
+    if (!province) {
26
+        console.error('❌ Province Sulawesi Tengah not found. Seed it first.');
27
+        return;
28
+    }
29
+
30
+    for (const name of cityNames) {
31
+        await prisma.city.upsert({
32
+            where: {
33
+                // Harus ada constraint unik di schema.prisma: @@unique([name, province_id], name: "name_province_id")
34
+                name_province_id: {
35
+                    name,
36
+                    province_id: province.id,
37
+                },
38
+            },
39
+            update: {
40
+                updatedAt: now().toDate(),
41
+            },
42
+            create: {
43
+                name,
44
+                province_id: province.id,
45
+                createdAt: now().toDate(),
46
+            },
47
+        });
48
+    }
49
+
50
+    console.log('✅ Sulawesi Tengah City seeded!.');
51
+};
52
+
53
+// const prisma = require('../../../src/prisma/PrismaClient.js');
54
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
55
+
56
+// const cityNames = [
57
+//     'Kabupaten Banggai',
58
+//     'Kabupaten Banggai Kepulauan',
59
+//     'Kabupaten Banggai Laut',
60
+//     'Kabupaten Buol',
61
+//     'Kabupaten Donggala',
62
+//     'Kabupaten Morowali',
63
+//     'Kabupaten Morowali Utara',
64
+//     'Kabupaten Parigi Moutong',
65
+//     'Kabupaten Poso',
66
+//     'Kabupaten Sigi',
67
+//     'Kabupaten Tojo Una-Una',
68
+//     'Kabupaten Tolitoli',
69
+//     'Kota Palu'
70
+
71
+//     // 13
72
+// ];
73
+
74
+// exports.seedSulawesiTengahCities = async () => {
75
+//     const province = await prisma.province.findFirst({
76
+//         where: { name: 'Sulawesi Tengah' },
77
+//     });
78
+
79
+//     if (!province) {
80
+//         console.error('❌ Province Sulawesi Tengah not found. Seed it first.');
81
+//         return;
82
+//     }
83
+
84
+//     for (const name of cityNames) {
85
+//         await prisma.city.upsert({
86
+//             where: {
87
+//                 name_province_id: {
88
+//                     name,
89
+//                     province_id: province.id,
90
+//                 },
91
+//             },
92
+//             update: { updatedAt: timeLocal.now().toDate() },
93
+//             create: {
94
+//                 name,
95
+//                 province_id: province.id,
96
+//                 createdAt: timeLocal.now().toDate()
97
+//             },
98
+//         });
99
+//     }
100
+
101
+//     console.log('✅ Sulawesi Tengah City seeded!.');
102
+// };

+ 0 - 54
prisma/seeders/city/SulawesiTenggaraCitySeeder.js

@@ -1,54 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bombana',
6
-    'Kabupaten Buton',
7
-    'Kabupaten Buton Selatan',
8
-    'Kabupaten Buton Tengah',
9
-    'Kabupaten Buton Utara',
10
-    'Kabupaten Kolaka',
11
-    'Kabupaten Kolaka Timur',
12
-    'Kabupaten Kolaka Utara',
13
-    'Kabupaten Konawe',
14
-    'Kabupaten Konawe Kepulauan',
15
-    'Kabupaten Konawe Selatan',
16
-    'Kabupaten Konawe Utara',
17
-    'Kabupaten Muna',
18
-    'Kabupaten Muna Barat',
19
-    'Kabupaten Wakatobi',
20
-    'Kota Baubau',
21
-    'Kota Kendari'
22
-
23
-    // 17
24
-];
25
-
26
-exports.seedSulawesiTenggaraCities = async () => {
27
-    const province = await prisma.province.findFirst({
28
-        where: { name: 'Sulawesi Tenggara' },
29
-    });
30
-
31
-    if (!province) {
32
-        console.error('❌ Province Sulawesi Tenggara not found. Seed it first.');
33
-        return;
34
-    }
35
-
36
-    for (const name of cityNames) {
37
-        await prisma.city.upsert({
38
-            where: {
39
-                name_province_id: {
40
-                    name,
41
-                    province_id: province.id,
42
-                },
43
-            },
44
-            update: { updatedAt: timeLocal.now().toDate() },
45
-            create: {
46
-                name,
47
-                province_id: province.id,
48
-                createdAt: timeLocal.now().toDate()
49
-            },
50
-        });
51
-    }
52
-
53
-    console.log('✅ Sulawesi Tenggara City seeded!.');
54
-};

+ 110 - 0
prisma/seeders/city/SulawesiTenggaraCitySeeder.ts

@@ -0,0 +1,110 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bombana',
6
+    'Kabupaten Buton',
7
+    'Kabupaten Buton Selatan',
8
+    'Kabupaten Buton Tengah',
9
+    'Kabupaten Buton Utara',
10
+    'Kabupaten Kolaka',
11
+    'Kabupaten Kolaka Timur',
12
+    'Kabupaten Kolaka Utara',
13
+    'Kabupaten Konawe',
14
+    'Kabupaten Konawe Kepulauan',
15
+    'Kabupaten Konawe Selatan',
16
+    'Kabupaten Konawe Utara',
17
+    'Kabupaten Muna',
18
+    'Kabupaten Muna Barat',
19
+    'Kabupaten Wakatobi',
20
+    'Kota Baubau',
21
+    'Kota Kendari'
22
+];
23
+
24
+export const seedSulawesiTenggaraCities = async (): Promise<void> => {
25
+    const province = await prisma.province.findFirst({
26
+        where: { name: 'Sulawesi Tenggara' },
27
+    });
28
+
29
+    if (!province) {
30
+        console.error('❌ Province Sulawesi Tenggara not found. Seed it first.');
31
+        return;
32
+    }
33
+
34
+    for (const name of cityNames) {
35
+        await prisma.city.upsert({
36
+            where: {
37
+                name_province_id: {
38
+                    name,
39
+                    province_id: province.id,
40
+                },
41
+            },
42
+            update: {
43
+                updatedAt: now().toDate(),
44
+            },
45
+            create: {
46
+                name,
47
+                province_id: province.id,
48
+                createdAt: now().toDate(),
49
+            },
50
+        });
51
+    }
52
+
53
+    console.log('✅ Sulawesi Tenggara City seeded!.');
54
+};
55
+
56
+
57
+// const prisma = require('../../../src/prisma/PrismaClient.js');
58
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
59
+
60
+// const cityNames = [
61
+//     'Kabupaten Bombana',
62
+//     'Kabupaten Buton',
63
+//     'Kabupaten Buton Selatan',
64
+//     'Kabupaten Buton Tengah',
65
+//     'Kabupaten Buton Utara',
66
+//     'Kabupaten Kolaka',
67
+//     'Kabupaten Kolaka Timur',
68
+//     'Kabupaten Kolaka Utara',
69
+//     'Kabupaten Konawe',
70
+//     'Kabupaten Konawe Kepulauan',
71
+//     'Kabupaten Konawe Selatan',
72
+//     'Kabupaten Konawe Utara',
73
+//     'Kabupaten Muna',
74
+//     'Kabupaten Muna Barat',
75
+//     'Kabupaten Wakatobi',
76
+//     'Kota Baubau',
77
+//     'Kota Kendari'
78
+
79
+//     // 17
80
+// ];
81
+
82
+// exports.seedSulawesiTenggaraCities = async () => {
83
+//     const province = await prisma.province.findFirst({
84
+//         where: { name: 'Sulawesi Tenggara' },
85
+//     });
86
+
87
+//     if (!province) {
88
+//         console.error('❌ Province Sulawesi Tenggara not found. Seed it first.');
89
+//         return;
90
+//     }
91
+
92
+//     for (const name of cityNames) {
93
+//         await prisma.city.upsert({
94
+//             where: {
95
+//                 name_province_id: {
96
+//                     name,
97
+//                     province_id: province.id,
98
+//                 },
99
+//             },
100
+//             update: { updatedAt: timeLocal.now().toDate() },
101
+//             create: {
102
+//                 name,
103
+//                 province_id: province.id,
104
+//                 createdAt: timeLocal.now().toDate()
105
+//             },
106
+//         });
107
+//     }
108
+
109
+//     console.log('✅ Sulawesi Tenggara City seeded!.');
110
+// };

+ 0 - 52
prisma/seeders/city/SulawesiUtaraCitySeeder.js

@@ -1,52 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Bolaang Mongondow',
6
-    'Kabupaten Bolaang Mongondow Selatan',
7
-    'Kabupaten Bolaang Mongondow Timur',
8
-    'Kabupaten Bolaang Mongondow Utara',
9
-    'Kabupaten Kepulauan Sangihe',
10
-    'Kabupaten Kepulauan Siau Tagulandang Biaro (Sitaro)',
11
-    'Kabupaten Kepulauan Talaud',
12
-    'Kabupaten Minahasa',
13
-    'Kabupaten Minahasa Selatan',
14
-    'Kabupaten Minahasa Tenggara',
15
-    'Kabupaten Minahasa Utara',
16
-    'Kota Bitung',
17
-    'Kota Kotamobagu',
18
-    'Kota Manado',
19
-    'Kota Tomohon'
20
-
21
-    // 15
22
-];
23
-
24
-exports.seedSulawesiUtaraCities = async () => {
25
-    const province = await prisma.province.findFirst({
26
-        where: { name: 'Sulawesi Utara' },
27
-    });
28
-
29
-    if (!province) {
30
-        console.error('❌ Province Sulawesi Utara not found. Seed it first.');
31
-        return;
32
-    }
33
-
34
-    for (const name of cityNames) {
35
-        await prisma.city.upsert({
36
-            where: {
37
-                name_province_id: {
38
-                    name,
39
-                    province_id: province.id,
40
-                },
41
-            },
42
-            update: { updatedAt: timeLocal.now().toDate() },
43
-            create: {
44
-                name,
45
-                province_id: province.id,
46
-                createdAt: timeLocal.now().toDate()
47
-            },
48
-        });
49
-    }
50
-
51
-    console.log('✅ Sulawesi Utara City seeded!.');
52
-};

+ 105 - 0
prisma/seeders/city/SulawesiUtaraCitySeeder.ts

@@ -0,0 +1,105 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Bolaang Mongondow',
6
+    'Kabupaten Bolaang Mongondow Selatan',
7
+    'Kabupaten Bolaang Mongondow Timur',
8
+    'Kabupaten Bolaang Mongondow Utara',
9
+    'Kabupaten Kepulauan Sangihe',
10
+    'Kabupaten Kepulauan Siau Tagulandang Biaro (Sitaro)',
11
+    'Kabupaten Kepulauan Talaud',
12
+    'Kabupaten Minahasa',
13
+    'Kabupaten Minahasa Selatan',
14
+    'Kabupaten Minahasa Tenggara',
15
+    'Kabupaten Minahasa Utara',
16
+    'Kota Bitung',
17
+    'Kota Kotamobagu',
18
+    'Kota Manado',
19
+    'Kota Tomohon'
20
+];
21
+
22
+export const seedSulawesiUtaraCities = async (): Promise<void> => {
23
+    const province = await prisma.province.findFirst({
24
+        where: { name: 'Sulawesi Utara' },
25
+    });
26
+
27
+    if (!province) {
28
+        console.error('❌ Province Sulawesi Utara not found. Seed it first.');
29
+        return;
30
+    }
31
+
32
+    for (const name of cityNames) {
33
+        await prisma.city.upsert({
34
+            where: {
35
+                name_province_id: {
36
+                    name,
37
+                    province_id: province.id,
38
+                },
39
+            },
40
+            update: {
41
+                updatedAt: now().toDate(),
42
+            },
43
+            create: {
44
+                name,
45
+                province_id: province.id,
46
+                createdAt: now().toDate(),
47
+            },
48
+        });
49
+    }
50
+
51
+    console.log('✅ Sulawesi Utara City seeded!.');
52
+};
53
+
54
+// const prisma = require('../../../src/prisma/PrismaClient.js');
55
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
56
+
57
+// const cityNames = [
58
+//     'Kabupaten Bolaang Mongondow',
59
+//     'Kabupaten Bolaang Mongondow Selatan',
60
+//     'Kabupaten Bolaang Mongondow Timur',
61
+//     'Kabupaten Bolaang Mongondow Utara',
62
+//     'Kabupaten Kepulauan Sangihe',
63
+//     'Kabupaten Kepulauan Siau Tagulandang Biaro (Sitaro)',
64
+//     'Kabupaten Kepulauan Talaud',
65
+//     'Kabupaten Minahasa',
66
+//     'Kabupaten Minahasa Selatan',
67
+//     'Kabupaten Minahasa Tenggara',
68
+//     'Kabupaten Minahasa Utara',
69
+//     'Kota Bitung',
70
+//     'Kota Kotamobagu',
71
+//     'Kota Manado',
72
+//     'Kota Tomohon'
73
+
74
+//     // 15
75
+// ];
76
+
77
+// exports.seedSulawesiUtaraCities = async () => {
78
+//     const province = await prisma.province.findFirst({
79
+//         where: { name: 'Sulawesi Utara' },
80
+//     });
81
+
82
+//     if (!province) {
83
+//         console.error('❌ Province Sulawesi Utara not found. Seed it first.');
84
+//         return;
85
+//     }
86
+
87
+//     for (const name of cityNames) {
88
+//         await prisma.city.upsert({
89
+//             where: {
90
+//                 name_province_id: {
91
+//                     name,
92
+//                     province_id: province.id,
93
+//                 },
94
+//             },
95
+//             update: { updatedAt: timeLocal.now().toDate() },
96
+//             create: {
97
+//                 name,
98
+//                 province_id: province.id,
99
+//                 createdAt: timeLocal.now().toDate()
100
+//             },
101
+//         });
102
+//     }
103
+
104
+//     console.log('✅ Sulawesi Utara City seeded!.');
105
+// };

+ 0 - 56
prisma/seeders/city/SumateraBaratCitySeeder.js

@@ -1,56 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Agam',
6
-    'Kabupaten Dharmasraya',
7
-    'Kabupaten Kepulauan Mentawai',
8
-    'Kabupaten Lima Puluh Kota',
9
-    'Kabupaten Padang Pariaman',
10
-    'Kabupaten Pasaman',
11
-    'Kabupaten Pasaman Barat',
12
-    'Kabupaten Pesisir Selatan',
13
-    'Kabupaten Sijunjung',
14
-    'Kabupaten Solok',
15
-    'Kabupaten Solok Selatan',
16
-    'Kabupaten Tanah Datar',
17
-    'Kota Bukittinggi',
18
-    'Kota Padang',
19
-    'Kota Padang Panjang',
20
-    'Kota Pariaman',
21
-    'Kota Payakumbuh',
22
-    'Kota Sawahlunto',
23
-    'Kota Solok'
24
-
25
-    // 19
26
-];
27
-
28
-exports.seedSumateraBaratCities = async () => {
29
-    const province = await prisma.province.findFirst({
30
-        where: { name: 'Sumatera Barat' },
31
-    });
32
-
33
-    if (!province) {
34
-        console.error('❌ Province Sumatera Barat not found. Seed it first.');
35
-        return;
36
-    }
37
-
38
-    for (const name of cityNames) {
39
-        await prisma.city.upsert({
40
-            where: {
41
-                name_province_id: {
42
-                    name,
43
-                    province_id: province.id,
44
-                },
45
-            },
46
-            update: { updatedAt: timeLocal.now().toDate() },
47
-            create: {
48
-                name,
49
-                province_id: province.id,
50
-                createdAt: timeLocal.now().toDate()
51
-            },
52
-        });
53
-    }
54
-
55
-    console.log('✅ Sumatera Barat City seeded!.');
56
-};

+ 113 - 0
prisma/seeders/city/SumateraBaratCitySeeder.ts

@@ -0,0 +1,113 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Agam',
6
+    'Kabupaten Dharmasraya',
7
+    'Kabupaten Kepulauan Mentawai',
8
+    'Kabupaten Lima Puluh Kota',
9
+    'Kabupaten Padang Pariaman',
10
+    'Kabupaten Pasaman',
11
+    'Kabupaten Pasaman Barat',
12
+    'Kabupaten Pesisir Selatan',
13
+    'Kabupaten Sijunjung',
14
+    'Kabupaten Solok',
15
+    'Kabupaten Solok Selatan',
16
+    'Kabupaten Tanah Datar',
17
+    'Kota Bukittinggi',
18
+    'Kota Padang',
19
+    'Kota Padang Panjang',
20
+    'Kota Pariaman',
21
+    'Kota Payakumbuh',
22
+    'Kota Sawahlunto',
23
+    'Kota Solok'
24
+];
25
+
26
+export const seedSumateraBaratCities = async (): Promise<void> => {
27
+    const province = await prisma.province.findFirst({
28
+        where: { name: 'Sumatera Barat' },
29
+    });
30
+
31
+    if (!province) {
32
+        console.error('❌ Province Sumatera Barat not found. Seed it first.');
33
+        return;
34
+    }
35
+
36
+    for (const name of cityNames) {
37
+        await prisma.city.upsert({
38
+            where: {
39
+                name_province_id: {
40
+                    name,
41
+                    province_id: province.id,
42
+                },
43
+            },
44
+            update: {
45
+                updatedAt: now().toDate(),
46
+            },
47
+            create: {
48
+                name,
49
+                province_id: province.id,
50
+                createdAt: now().toDate(),
51
+            },
52
+        });
53
+    }
54
+
55
+    console.log('✅ Sumatera Barat City seeded!.');
56
+};
57
+
58
+// const prisma = require('../../../src/prisma/PrismaClient.js');
59
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
60
+
61
+// const cityNames = [
62
+//     'Kabupaten Agam',
63
+//     'Kabupaten Dharmasraya',
64
+//     'Kabupaten Kepulauan Mentawai',
65
+//     'Kabupaten Lima Puluh Kota',
66
+//     'Kabupaten Padang Pariaman',
67
+//     'Kabupaten Pasaman',
68
+//     'Kabupaten Pasaman Barat',
69
+//     'Kabupaten Pesisir Selatan',
70
+//     'Kabupaten Sijunjung',
71
+//     'Kabupaten Solok',
72
+//     'Kabupaten Solok Selatan',
73
+//     'Kabupaten Tanah Datar',
74
+//     'Kota Bukittinggi',
75
+//     'Kota Padang',
76
+//     'Kota Padang Panjang',
77
+//     'Kota Pariaman',
78
+//     'Kota Payakumbuh',
79
+//     'Kota Sawahlunto',
80
+//     'Kota Solok'
81
+
82
+//     // 19
83
+// ];
84
+
85
+// exports.seedSumateraBaratCities = async () => {
86
+//     const province = await prisma.province.findFirst({
87
+//         where: { name: 'Sumatera Barat' },
88
+//     });
89
+
90
+//     if (!province) {
91
+//         console.error('❌ Province Sumatera Barat not found. Seed it first.');
92
+//         return;
93
+//     }
94
+
95
+//     for (const name of cityNames) {
96
+//         await prisma.city.upsert({
97
+//             where: {
98
+//                 name_province_id: {
99
+//                     name,
100
+//                     province_id: province.id,
101
+//                 },
102
+//             },
103
+//             update: { updatedAt: timeLocal.now().toDate() },
104
+//             create: {
105
+//                 name,
106
+//                 province_id: province.id,
107
+//                 createdAt: timeLocal.now().toDate()
108
+//             },
109
+//         });
110
+//     }
111
+
112
+//     console.log('✅ Sumatera Barat City seeded!.');
113
+// };

+ 0 - 54
prisma/seeders/city/SumateraSelatanCitySeeder.js

@@ -1,54 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Banyuasin',
6
-    'Kabupaten Empat Lawang',
7
-    'Kabupaten Lahat',
8
-    'Kabupaten Muara Enim',
9
-    'Kabupaten Musi Banyuasin',
10
-    'Kabupaten Musi Rawas',
11
-    'Kabupaten Musi Rawas Utara',
12
-    'Kabupaten Ogan Ilir',
13
-    'Kabupaten Ogan Komering Ilir',
14
-    'Kabupaten Ogan Komering Ulu',
15
-    'Kabupaten Ogan Komering Ulu Selatan',
16
-    'Kabupaten Ogan Komering Ulu Timur',
17
-    'Kabupaten Penukal Abab Lematang Ilir',
18
-    'Kota Lubuklinggau',
19
-    'Kota Pagar Alam',
20
-    'Kota Palembang',
21
-    'Kota Prabumulih'
22
-
23
-    // 17
24
-];
25
-
26
-exports.seedSumateraSelatanCities = async () => {
27
-    const province = await prisma.province.findFirst({
28
-        where: { name: 'Sumatera Selatan' },
29
-    });
30
-
31
-    if (!province) {
32
-        console.error('❌ Province Sumatera Selatan not found. Seed it first.');
33
-        return;
34
-    }
35
-
36
-    for (const name of cityNames) {
37
-        await prisma.city.upsert({
38
-            where: {
39
-                name_province_id: {
40
-                    name,
41
-                    province_id: province.id,
42
-                },
43
-            },
44
-            update: { updatedAt: timeLocal.now().toDate() },
45
-            create: {
46
-                name,
47
-                province_id: province.id,
48
-                createdAt: timeLocal.now().toDate()
49
-            },
50
-        });
51
-    }
52
-
53
-    console.log('✅ Sumatera Selatan City seeded!.');
54
-};

+ 110 - 0
prisma/seeders/city/SumateraSelatanCitySeeder.ts

@@ -0,0 +1,110 @@
1
+import prisma from '../../../src/prisma/PrismaClient';
2
+import { now } from '../../../src/utils/TimeLocal';
3
+
4
+const cityNames: string[] = [
5
+    'Kabupaten Banyuasin',
6
+    'Kabupaten Empat Lawang',
7
+    'Kabupaten Lahat',
8
+    'Kabupaten Muara Enim',
9
+    'Kabupaten Musi Banyuasin',
10
+    'Kabupaten Musi Rawas',
11
+    'Kabupaten Musi Rawas Utara',
12
+    'Kabupaten Ogan Ilir',
13
+    'Kabupaten Ogan Komering Ilir',
14
+    'Kabupaten Ogan Komering Ulu',
15
+    'Kabupaten Ogan Komering Ulu Selatan',
16
+    'Kabupaten Ogan Komering Ulu Timur',
17
+    'Kabupaten Penukal Abab Lematang Ilir',
18
+    'Kota Lubuklinggau',
19
+    'Kota Pagar Alam',
20
+    'Kota Palembang',
21
+    'Kota Prabumulih'
22
+];
23
+
24
+export const seedSumateraSelatanCities = async (): Promise<void> => {
25
+    const province = await prisma.province.findFirst({
26
+        where: { name: 'Sumatera Selatan' },
27
+    });
28
+
29
+    if (!province) {
30
+        console.error('❌ Province Sumatera Selatan not found. Seed it first.');
31
+        return;
32
+    }
33
+
34
+    for (const name of cityNames) {
35
+        await prisma.city.upsert({
36
+            where: {
37
+                // Field composite unique [name, province_id] harus didefinisikan di schema.prisma
38
+                name_province_id: {
39
+                    name,
40
+                    province_id: province.id,
41
+                },
42
+            },
43
+            update: {
44
+                updatedAt: now().toDate(),
45
+            },
46
+            create: {
47
+                name,
48
+                province_id: province.id,
49
+                createdAt: now().toDate(),
50
+            },
51
+        });
52
+    }
53
+
54
+    console.log('✅ Sumatera Selatan City seeded!.');
55
+};
56
+
57
+// const prisma = require('../../../src/prisma/PrismaClient.js');
58
+// const timeLocal = require('../../../src/utils/TimeLocal.js')
59
+
60
+// const cityNames = [
61
+//     'Kabupaten Banyuasin',
62
+//     'Kabupaten Empat Lawang',
63
+//     'Kabupaten Lahat',
64
+//     'Kabupaten Muara Enim',
65
+//     'Kabupaten Musi Banyuasin',
66
+//     'Kabupaten Musi Rawas',
67
+//     'Kabupaten Musi Rawas Utara',
68
+//     'Kabupaten Ogan Ilir',
69
+//     'Kabupaten Ogan Komering Ilir',
70
+//     'Kabupaten Ogan Komering Ulu',
71
+//     'Kabupaten Ogan Komering Ulu Selatan',
72
+//     'Kabupaten Ogan Komering Ulu Timur',
73
+//     'Kabupaten Penukal Abab Lematang Ilir',
74
+//     'Kota Lubuklinggau',
75
+//     'Kota Pagar Alam',
76
+//     'Kota Palembang',
77
+//     'Kota Prabumulih'
78
+
79
+//     // 17
80
+// ];
81
+
82
+// exports.seedSumateraSelatanCities = async () => {
83
+//     const province = await prisma.province.findFirst({
84
+//         where: { name: 'Sumatera Selatan' },
85
+//     });
86
+
87
+//     if (!province) {
88
+//         console.error('❌ Province Sumatera Selatan not found. Seed it first.');
89
+//         return;
90
+//     }
91
+
92
+//     for (const name of cityNames) {
93
+//         await prisma.city.upsert({
94
+//             where: {
95
+//                 name_province_id: {
96
+//                     name,
97
+//                     province_id: province.id,
98
+//                 },
99
+//             },
100
+//             update: { updatedAt: timeLocal.now().toDate() },
101
+//             create: {
102
+//                 name,
103
+//                 province_id: province.id,
104
+//                 createdAt: timeLocal.now().toDate()
105
+//             },
106
+//         });
107
+//     }
108
+
109
+//     console.log('✅ Sumatera Selatan City seeded!.');
110
+// };

+ 0 - 70
prisma/seeders/city/SumateraUtaraCitySeeder.js

@@ -1,70 +0,0 @@
1
-const prisma = require('../../../src/prisma/PrismaClient.js');
2
-const timeLocal = require('../../../src/utils/TimeLocal.js')
3
-
4
-const cityNames = [
5
-    'Kabupaten Asahan',
6
-    'Kabupaten Batu Bara',
7
-    'Kabupaten Dairi',
8
-    'Kabupaten Deli Serdang',
9
-    'Kabupaten Humbang Hasundutan',
10
-    'Kabupaten Karo',
11
-    'Kabupaten Labuhanbatu',
12
-    'Kabupaten Labuhanbatu Selatan',
13
-    'Kabupaten Labuhanbatu Utara',
14
-    'Kabupaten Langkat',
15
-    'Kabupaten Mandailing Natal',
16
-    'Kabupaten Nias',
17
-    'Kabupaten Nias Barat',
18
-    'Kabupaten Nias Selatan',
19
-    'Kabupaten Nias Utara',
20
-    'Kabupaten Padang Lawas',
21
-    'Kabupaten Padang Lawas Utara',
22
-    'Kabupaten Pakpak Bharat',
23
-    'Kabupaten Samosir',
24
-    'Kabupaten Serdang Bedagai',
25
-    'Kabupaten Simalungun',
26
-    'Kabupaten Tapanuli Selatan',
27
-    'Kabupaten Tapanuli Tengah',
28
-    'Kabupaten Tapanuli Utara',
29
-    'Kabupaten Toba',
30
-    'Kota Binjai',
31
-    'Kota Gunungsitoli',
32
-    'Kota Medan',
33
-    'Kota Padangsidimpuan',
34
-    'Kota Pematangsiantar',
35
-    'Kota Sibolga',
36
-    'Kota Tanjungbalai',
37
-    'Kota Tebing Tinggi'
38
-
39
-    // 33
40
-];
41
-
42
-exports.seedSumateraUtaraCities = async () => {
43
-    const province = await prisma.province.findFirst({
44
-        where: { name: 'Sumatera Utara' },
45
-    });
46
-
47
-    if (!province) {
48
-        console.error('❌ Province Sumatera Utara not found. Seed it first.');
49
-        return;
50
-    }
51
-
52
-    for (const name of cityNames) {
53
-        await prisma.city.upsert({
54
-            where: {
55
-                name_province_id: {
56
-                    name,
57
-                    province_id: province.id,
58
-                },
59
-            },
60
-            update: { updatedAt: timeLocal.now().toDate() },
61
-            create: {
62
-                name,
63
-                province_id: province.id,
64
-                createdAt: timeLocal.now().toDate()
65
-            },
66
-        });
67
-    }
68
-
69
-    console.log('✅ Sumatera Utara City seeded!.');
70
-};

+ 0 - 0
prisma/seeders/city/SumateraUtaraCitySeeder.ts


Some files were not shown because too many files changed in this diff