001/*
002 * Copyright 2012-2017 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 = "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         * Check 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         * Drop the database schema first.
058         */
059        private boolean dropFirst;
060
061        /**
062         * Enable liquibase support.
063         */
064        private boolean enabled = true;
065
066        /**
067         * Login user of the database to migrate.
068         */
069        private String user;
070
071        /**
072         * Login password of the database to migrate.
073         */
074        private String password;
075
076        /**
077         * JDBC url of the database to migrate. If not set, the primary configured data source
078         * is used.
079         */
080        private String url;
081
082        /**
083         * Comma-separated list of runtime labels to use.
084         */
085        private String labels;
086
087        /**
088         * Change log parameters.
089         */
090        private Map<String, String> parameters;
091
092        /**
093         * File to which rollback SQL will be written when an update is performed.
094         */
095        private File rollbackFile;
096
097        public String getChangeLog() {
098                return this.changeLog;
099        }
100
101        public void setChangeLog(String changeLog) {
102                Assert.notNull(changeLog, "ChangeLog must not be null");
103                this.changeLog = changeLog;
104        }
105
106        public boolean isCheckChangeLogLocation() {
107                return this.checkChangeLogLocation;
108        }
109
110        public void setCheckChangeLogLocation(boolean checkChangeLogLocation) {
111                this.checkChangeLogLocation = checkChangeLogLocation;
112        }
113
114        public String getContexts() {
115                return this.contexts;
116        }
117
118        public void setContexts(String contexts) {
119                this.contexts = contexts;
120        }
121
122        public String getDefaultSchema() {
123                return this.defaultSchema;
124        }
125
126        public void setDefaultSchema(String defaultSchema) {
127                this.defaultSchema = defaultSchema;
128        }
129
130        public boolean isDropFirst() {
131                return this.dropFirst;
132        }
133
134        public void setDropFirst(boolean dropFirst) {
135                this.dropFirst = dropFirst;
136        }
137
138        public boolean isEnabled() {
139                return this.enabled;
140        }
141
142        public void setEnabled(boolean enabled) {
143                this.enabled = enabled;
144        }
145
146        public String getUser() {
147                return this.user;
148        }
149
150        public void setUser(String user) {
151                this.user = user;
152        }
153
154        public String getPassword() {
155                return this.password;
156        }
157
158        public void setPassword(String password) {
159                this.password = password;
160        }
161
162        public String getUrl() {
163                return this.url;
164        }
165
166        public void setUrl(String url) {
167                this.url = url;
168        }
169
170        public String getLabels() {
171                return this.labels;
172        }
173
174        public void setLabels(String labels) {
175                this.labels = labels;
176        }
177
178        public Map<String, String> getParameters() {
179                return this.parameters;
180        }
181
182        public void setParameters(Map<String, String> parameters) {
183                this.parameters = parameters;
184        }
185
186        public File getRollbackFile() {
187                return this.rollbackFile;
188        }
189
190        public void setRollbackFile(File rollbackFile) {
191                this.rollbackFile = rollbackFile;
192        }
193
194}