001/*
002 * Copyright 2012-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.autoconfigure.liquibase;
018
019import java.io.File;
020import java.util.Map;
021
022import liquibase.integration.spring.SpringLiquibase;
023
024import org.springframework.boot.context.properties.ConfigurationProperties;
025import org.springframework.util.Assert;
026
027/**
028 * Configuration properties to configure {@link SpringLiquibase}.
029 *
030 * @author Marcel Overdijk
031 * @since 1.1.0
032 */
033@ConfigurationProperties(prefix = "spring.liquibase", ignoreUnknownFields = false)
034public class LiquibaseProperties {
035
036        /**
037         * Change log configuration path.
038         */
039        private String changeLog = "classpath:/db/changelog/db.changelog-master.yaml";
040
041        /**
042         * Whether to check that the change log location exists.
043         */
044        private boolean checkChangeLogLocation = true;
045
046        /**
047         * Comma-separated list of runtime contexts to use.
048         */
049        private String contexts;
050
051        /**
052         * Default database schema.
053         */
054        private String defaultSchema;
055
056        /**
057         * Schema to use for Liquibase objects.
058         */
059        private String liquibaseSchema;
060
061        /**
062         * Tablespace to use for Liquibase objects.
063         */
064        private String liquibaseTablespace;
065
066        /**
067         * Name of table to use for tracking change history.
068         */
069        private String databaseChangeLogTable = "DATABASECHANGELOG";
070
071        /**
072         * Name of table to use for tracking concurrent Liquibase usage.
073         */
074        private String databaseChangeLogLockTable = "DATABASECHANGELOGLOCK";
075
076        /**
077         * Whether to first drop the database schema.
078         */
079        private boolean dropFirst;
080
081        /**
082         * Whether to enable Liquibase support.
083         */
084        private boolean enabled = true;
085
086        /**
087         * Login user of the database to migrate.
088         */
089        private String user;
090
091        /**
092         * Login password of the database to migrate.
093         */
094        private String password;
095
096        /**
097         * JDBC URL of the database to migrate. If not set, the primary configured data source
098         * is used.
099         */
100        private String url;
101
102        /**
103         * Comma-separated list of runtime labels to use.
104         */
105        private String labels;
106
107        /**
108         * Change log parameters.
109         */
110        private Map<String, String> parameters;
111
112        /**
113         * File to which rollback SQL is written when an update is performed.
114         */
115        private File rollbackFile;
116
117        /**
118         * Whether rollback should be tested before update is performed.
119         */
120        private boolean testRollbackOnUpdate;
121
122        public String getChangeLog() {
123                return this.changeLog;
124        }
125
126        public void setChangeLog(String changeLog) {
127                Assert.notNull(changeLog, "ChangeLog must not be null");
128                this.changeLog = changeLog;
129        }
130
131        public boolean isCheckChangeLogLocation() {
132                return this.checkChangeLogLocation;
133        }
134
135        public void setCheckChangeLogLocation(boolean checkChangeLogLocation) {
136                this.checkChangeLogLocation = checkChangeLogLocation;
137        }
138
139        public String getContexts() {
140                return this.contexts;
141        }
142
143        public void setContexts(String contexts) {
144                this.contexts = contexts;
145        }
146
147        public String getDefaultSchema() {
148                return this.defaultSchema;
149        }
150
151        public void setDefaultSchema(String defaultSchema) {
152                this.defaultSchema = defaultSchema;
153        }
154
155        public String getLiquibaseSchema() {
156                return this.liquibaseSchema;
157        }
158
159        public void setLiquibaseSchema(String liquibaseSchema) {
160                this.liquibaseSchema = liquibaseSchema;
161        }
162
163        public String getLiquibaseTablespace() {
164                return this.liquibaseTablespace;
165        }
166
167        public void setLiquibaseTablespace(String liquibaseTablespace) {
168                this.liquibaseTablespace = liquibaseTablespace;
169        }
170
171        public String getDatabaseChangeLogTable() {
172                return this.databaseChangeLogTable;
173        }
174
175        public void setDatabaseChangeLogTable(String databaseChangeLogTable) {
176                this.databaseChangeLogTable = databaseChangeLogTable;
177        }
178
179        public String getDatabaseChangeLogLockTable() {
180                return this.databaseChangeLogLockTable;
181        }
182
183        public void setDatabaseChangeLogLockTable(String databaseChangeLogLockTable) {
184                this.databaseChangeLogLockTable = databaseChangeLogLockTable;
185        }
186
187        public boolean isDropFirst() {
188                return this.dropFirst;
189        }
190
191        public void setDropFirst(boolean dropFirst) {
192                this.dropFirst = dropFirst;
193        }
194
195        public boolean isEnabled() {
196                return this.enabled;
197        }
198
199        public void setEnabled(boolean enabled) {
200                this.enabled = enabled;
201        }
202
203        public String getUser() {
204                return this.user;
205        }
206
207        public void setUser(String user) {
208                this.user = user;
209        }
210
211        public String getPassword() {
212                return this.password;
213        }
214
215        public void setPassword(String password) {
216                this.password = password;
217        }
218
219        public String getUrl() {
220                return this.url;
221        }
222
223        public void setUrl(String url) {
224                this.url = url;
225        }
226
227        public String getLabels() {
228                return this.labels;
229        }
230
231        public void setLabels(String labels) {
232                this.labels = labels;
233        }
234
235        public Map<String, String> getParameters() {
236                return this.parameters;
237        }
238
239        public void setParameters(Map<String, String> parameters) {
240                this.parameters = parameters;
241        }
242
243        public File getRollbackFile() {
244                return this.rollbackFile;
245        }
246
247        public void setRollbackFile(File rollbackFile) {
248                this.rollbackFile = rollbackFile;
249        }
250
251        public boolean isTestRollbackOnUpdate() {
252                return this.testRollbackOnUpdate;
253        }
254
255        public void setTestRollbackOnUpdate(boolean testRollbackOnUpdate) {
256                this.testRollbackOnUpdate = testRollbackOnUpdate;
257        }
258
259}