File tree Expand file tree Collapse file tree 3 files changed +25
-12
lines changed
backend/spring-boot/src/main
java/org/bugzkit/api/shared/config Expand file tree Collapse file tree 3 files changed +25
-12
lines changed Original file line number Diff line number Diff line change @@ -45,19 +45,13 @@ public DataInit(
4545
4646 @ Override
4747 public void run (ApplicationArguments args ) {
48- saveRoles ();
48+ initRoles ();
4949 saveUsers ();
5050 }
5151
52- private void saveRoles () {
53- userRole =
54- roleRepository
55- .findByName (RoleName .USER )
56- .orElseGet (() -> roleRepository .save (new Role (RoleName .USER )));
57- adminRole =
58- roleRepository
59- .findByName (RoleName .ADMIN )
60- .orElseGet (() -> roleRepository .save (new Role (RoleName .ADMIN )));
52+ private void initRoles () {
53+ userRole = roleRepository .findByName (RoleName .USER ).orElseThrow ();
54+ adminRole = roleRepository .findByName (RoleName .ADMIN ).orElseThrow ();
6155 }
6256
6357 private void saveUsers () {
Original file line number Diff line number Diff line change 1+ package org .bugzkit .api .shared .config ;
2+
3+ import org .springframework .boot .flyway .autoconfigure .FlywayMigrationStrategy ;
4+ import org .springframework .context .annotation .Bean ;
5+ import org .springframework .context .annotation .Configuration ;
6+ import org .springframework .context .annotation .Profile ;
7+
8+ @ Configuration
9+ @ Profile ("dev" )
10+ class FlywayDevConfig {
11+
12+ @ Bean
13+ FlywayMigrationStrategy cleanMigrate () {
14+ return flyway -> {
15+ flyway .clean ();
16+ flyway .migrate ();
17+ };
18+ }
19+ }
Original file line number Diff line number Diff line change @@ -12,10 +12,10 @@ spring:
1212 url : jdbc:postgresql://${POSTGRES_HOST:localhost}:${POSTGRES_PORT:5432}/${POSTGRES_DATABASE:bugzkit}
1313 password : ${POSTGRES_PASSWORD:root}
1414 flyway :
15- enabled : false
15+ clean-disabled : false
1616 jpa :
1717 hibernate :
18- ddl-auto : create
18+ ddl-auto : validate
1919 data :
2020 redis :
2121 host : ${REDIS_HOST:localhost}
You can’t perform that action at this time.
0 commit comments