|
4 | 4 | import java.nio.file.Paths;
|
5 | 5 | import java.sql.Connection;
|
6 | 6 | import java.sql.DriverManager;
|
| 7 | +import java.util.HashMap; |
7 | 8 | import java.util.Map;
|
8 | 9 |
|
9 | 10 | import javax.sql.DataSource;
|
|
20 | 21 | import liquibase.database.Database;
|
21 | 22 | import liquibase.database.DatabaseFactory;
|
22 | 23 | import liquibase.database.jvm.JdbcConnection;
|
| 24 | +import liquibase.exception.LiquibaseException; |
23 | 25 | import liquibase.resource.ClassLoaderResourceAccessor;
|
24 | 26 | import liquibase.resource.CompositeResourceAccessor;
|
25 | 27 | import liquibase.resource.DirectoryResourceAccessor;
|
@@ -126,7 +128,8 @@ public Liquibase createLiquibase() {
|
126 | 128 | database.setDefaultSchemaName(config.defaultSchemaName.get());
|
127 | 129 | }
|
128 | 130 | }
|
129 |
| - Liquibase liquibase = new Liquibase(parsedChangeLog, resourceAccessor, database); |
| 131 | + Liquibase liquibase = new QuarkusLiquibase(parsedChangeLog, resourceAccessor, database, |
| 132 | + createResettableSystemProperties()); |
130 | 133 |
|
131 | 134 | for (Map.Entry<String, String> entry : config.changeLogParameters.entrySet()) {
|
132 | 135 | liquibase.getChangeLogParameters().set(entry.getKey(), entry.getValue());
|
@@ -166,10 +169,37 @@ public String getDataSourceName() {
|
166 | 169 | }
|
167 | 170 |
|
168 | 171 | public ResettableSystemProperties createResettableSystemProperties() {
|
169 |
| - if (config.allowDuplicatedChangesetIdentifiers.isEmpty()) { |
170 |
| - return ResettableSystemProperties.empty(); |
| 172 | + Map<String, String> resettableProperties = new HashMap<>(); |
| 173 | + |
| 174 | + if (config.allowDuplicatedChangesetIdentifiers.isPresent()) { |
| 175 | + resettableProperties.put("liquibase.allowDuplicatedChangesetIdentifiers", |
| 176 | + config.allowDuplicatedChangesetIdentifiers.get().toString()); |
| 177 | + } |
| 178 | + |
| 179 | + if (!config.secureParsing) { |
| 180 | + resettableProperties.put("liquibase.secureParsing", "false"); |
| 181 | + } |
| 182 | + |
| 183 | + return new ResettableSystemProperties(resettableProperties); |
| 184 | + } |
| 185 | + |
| 186 | + private static class QuarkusLiquibase extends Liquibase { |
| 187 | + |
| 188 | + private final ResettableSystemProperties resettableSystemProperties; |
| 189 | + |
| 190 | + public QuarkusLiquibase(String changeLogFile, ResourceAccessor resourceAccessor, Database database, |
| 191 | + ResettableSystemProperties resettableSystemProperties) { |
| 192 | + super(changeLogFile, resourceAccessor, database); |
| 193 | + this.resettableSystemProperties = resettableSystemProperties; |
| 194 | + } |
| 195 | + |
| 196 | + @Override |
| 197 | + public void close() throws LiquibaseException { |
| 198 | + try { |
| 199 | + super.close(); |
| 200 | + } finally { |
| 201 | + resettableSystemProperties.close(); |
| 202 | + } |
171 | 203 | }
|
172 |
| - return ResettableSystemProperties.of("liquibase.allowDuplicatedChangesetIdentifiers", |
173 |
| - config.allowDuplicatedChangesetIdentifiers.get().toString()); |
174 | 204 | }
|
175 | 205 | }
|
0 commit comments