|
1 | 1 | package de.tum.cit.aet.artemis.core.config; |
2 | 2 |
|
3 | 3 | import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; |
4 | | -import static tech.jhipster.config.JHipsterConstants.SPRING_PROFILE_NO_LIQUIBASE; |
5 | 4 | import static tech.jhipster.config.JHipsterConstants.SPRING_PROFILE_TEST; |
6 | 5 |
|
7 | 6 | import java.sql.SQLException; |
|
12 | 11 | import org.slf4j.Logger; |
13 | 12 | import org.slf4j.LoggerFactory; |
14 | 13 | import org.springframework.beans.factory.ObjectProvider; |
| 14 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty; |
15 | 15 | import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; |
16 | 16 | import org.springframework.boot.autoconfigure.liquibase.LiquibaseDataSource; |
17 | 17 | import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties; |
|
36 | 36 | @Profile(PROFILE_CORE) |
37 | 37 | @Configuration |
38 | 38 | @Lazy |
| 39 | +@ConditionalOnBooleanProperty(prefix = "spring.liquibase", name = "enabled", matchIfMissing = true) |
39 | 40 | public class LiquibaseConfiguration { |
40 | 41 |
|
41 | 42 | private static final Logger log = LoggerFactory.getLogger(LiquibaseConfiguration.class); |
@@ -74,7 +75,7 @@ public SpringLiquibase liquibase(@LiquibaseDataSource ObjectProvider<DataSource> |
74 | 75 | this.dataSource = dataSourceObjectProvider.getIfUnique(); |
75 | 76 | this.currentVersionString = buildProperties.getVersion(); |
76 | 77 |
|
77 | | - if (!env.acceptsProfiles(Profiles.of(SPRING_PROFILE_TEST)) && !env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_NO_LIQUIBASE))) { |
| 78 | + if (!env.acceptsProfiles(Profiles.of(SPRING_PROFILE_TEST))) { |
78 | 79 | this.databaseMigration = new DatabaseMigration(currentVersionString, dataSource, optionalHeliosClient); |
79 | 80 | databaseMigration.checkMigrationPath(); |
80 | 81 | } |
@@ -119,8 +120,8 @@ public SpringLiquibase liquibase(@LiquibaseDataSource ObjectProvider<DataSource> |
119 | 120 | */ |
120 | 121 | @EventListener |
121 | 122 | public void storeCurrentVersionToDatabase(ApplicationReadyEvent event) { |
122 | | - if (env.acceptsProfiles(Profiles.of(SPRING_PROFILE_TEST)) || env.acceptsProfiles(Profiles.of(SPRING_PROFILE_NO_LIQUIBASE))) { |
123 | | - return; // Do not perform any operations if the application is running in the test or no-liquibase profile. |
| 123 | + if (env.acceptsProfiles(Profiles.of(SPRING_PROFILE_TEST))) { |
| 124 | + return; // Do not perform any operations if the application is running in the test profile. |
124 | 125 | } |
125 | 126 |
|
126 | 127 | String sqlStatement = this.databaseMigration.getPreviousVersionString() == null ? "INSERT INTO artemis_version (latest_version) VALUES(?);" |
|
0 commit comments