Skip to content

Commit 1127bed

Browse files
author
Adnane Miliari
committed
🌱 implement initial data seeding with SQL scripts instead of DbSeeder classes
1 parent bb3f9d3 commit 1127bed

File tree

18 files changed

+74
-331
lines changed

18 files changed

+74
-331
lines changed

‎common/src/main/resources/shared-application-default.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ spring:
3131
format_sql: true
3232
show-sql: true
3333
open-in-view: false
34+
defer-datasource-initialization: true
35+
sql:
36+
init:
37+
mode: always
38+
data-locations: classpath*:db/data.sql
39+
platform: postgresql
3440
rabbitmq:
3541
addresses: localhost:5672
3642

‎common/src/main/resources/shared-application-docker.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ spring:
1010
password: password
1111
rabbitmq:
1212
addresses: rabbitmq:5672
13+
sql:
14+
init:
15+
mode: always
16+
data-locations: classpath*:db/data.sql
17+
platform: postgresql
1318

1419
eureka:
1520
client:

‎common/src/main/resources/shared-application-eks.yml‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ management:
55

66
spring:
77
datasource:
8-
url: jdbc:postgresql://demo-microservices.csetxdk14qax.us-east-1.rds.amazonaws.com:5432/${spring.application.name}
9-
username: ${DB_USERNAME}
10-
password: ${DB_PASSWORD}
8+
url: jdbc:postgresql://postgres:5432/${spring.application.name}
9+
username: miliariadnane
10+
password: password
1111
rabbitmq:
1212
addresses: rabbitmq:5672
13-
jpa:
14-
hibernate:
15-
ddl-auto: update
13+
sql:
14+
init:
15+
mode: always
16+
data-locations: classpath*:db/data.sql
17+
platform: postgresql
1618

19+
eureka:
20+
client:
21+
service-url:
22+
defaultZone: http://eureka-server:8761/eureka
23+
enabled: false

‎common/src/main/resources/shared-application-kube.yml‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ management:
55

66
spring:
77
datasource:
8-
url: jdbc:postgresql://postgres:5432/${spring.application.name}
9-
username: miliariadnane
10-
password: password
8+
url: jdbc:postgresql://demo-microservices.csetxdk14qax.us-east-1.rds.amazonaws.com:5432/${spring.application.name}
9+
username: ${DB_USERNAME}
10+
password: ${DB_PASSWORD}
1111
rabbitmq:
1212
addresses: rabbitmq:5672
13-
14-
eureka:
15-
client:
16-
service-url:
17-
defaultZone: http://eureka-server:8761/eureka
18-
enabled: false
13+
jpa:
14+
hibernate:
15+
ddl-auto: update
16+
sql:
17+
init:
18+
mode: never

‎customer/src/main/java/dev/nano/customer/CustomerDbSeeder.java‎

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
INSERT INTO customer (id, name, email, phone, address)
2+
VALUES (nextval('customer_sequence'), 'John Smith', '[email protected]', '+1234567890', '123 Main St, New York, NY'),
3+
(nextval('customer_sequence'), 'Emma Wilson', '[email protected]', '+1987654321',
4+
'456 Park Ave, London, UK'),
5+
(nextval('customer_sequence'), 'Mohammed Ali', '[email protected]', '+212661234567',
6+
'Marina Street, Casablanca, Morocco'),
7+
(nextval('customer_sequence'), 'Sarah Chen', '[email protected]', '+8613912345678',
8+
'789 Nanjing Road, Shanghai, China');

‎notification/src/main/java/dev/nano/notification/NotificationDbSeeder.java‎

Lines changed: 0 additions & 27 deletions
This file was deleted.

‎notification/src/main/resources/application-docker.yml‎

Lines changed: 0 additions & 63 deletions
This file was deleted.

‎notification/src/main/resources/application-eks.yml‎

Lines changed: 0 additions & 55 deletions
This file was deleted.

‎notification/src/main/resources/application-kube.yml‎

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)