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.flyway; 018 019import java.util.ArrayList; 020import java.util.Collections; 021import java.util.List; 022 023import org.flywaydb.core.Flyway; 024 025import org.springframework.boot.context.properties.ConfigurationProperties; 026 027/** 028 * Configuration properties for Flyway database migrations. These are only the properties 029 * that Spring needs to validate and enable the migrations. If you want to control the 030 * location or format of the scripts you can use the same prefix ("flyway") to inject 031 * properties into the {@link Flyway} instance. 032 * 033 * @author Dave Syer 034 * @since 1.1.0 035 */ 036@ConfigurationProperties(prefix = "flyway", ignoreUnknownFields = true) 037public class FlywayProperties { 038 039 /** 040 * Locations of migrations scripts. Can contain the special "{vendor}" placeholder to 041 * use vendor-specific locations. 042 */ 043 private List<String> locations = new ArrayList<String>( 044 Collections.singletonList("db/migration")); 045 046 /** 047 * Check that migration scripts location exists. 048 */ 049 private boolean checkLocation = false; 050 051 /** 052 * Enable flyway. 053 */ 054 private boolean enabled = true; 055 056 /** 057 * Login user of the database to migrate. 058 */ 059 private String user; 060 061 /** 062 * Login password of the database to migrate. 063 */ 064 private String password; 065 066 /** 067 * JDBC url of the database to migrate. If not set, the primary configured data source 068 * is used. 069 */ 070 private String url; 071 072 /** 073 * SQL statements to execute to initialize a connection immediately after obtaining 074 * it. 075 */ 076 private List<String> initSqls = new ArrayList<String>(); 077 078 public void setLocations(List<String> locations) { 079 this.locations = locations; 080 } 081 082 public List<String> getLocations() { 083 return this.locations; 084 } 085 086 public void setCheckLocation(boolean checkLocation) { 087 this.checkLocation = checkLocation; 088 } 089 090 public boolean isCheckLocation() { 091 return this.checkLocation; 092 } 093 094 public boolean isEnabled() { 095 return this.enabled; 096 } 097 098 public void setEnabled(boolean enabled) { 099 this.enabled = enabled; 100 } 101 102 public String getUser() { 103 return this.user; 104 } 105 106 public void setUser(String user) { 107 this.user = user; 108 } 109 110 public String getPassword() { 111 return (this.password == null ? "" : this.password); 112 } 113 114 public void setPassword(String password) { 115 this.password = password; 116 } 117 118 public String getUrl() { 119 return this.url; 120 } 121 122 public void setUrl(String url) { 123 this.url = url; 124 } 125 126 public List<String> getInitSqls() { 127 return this.initSqls; 128 } 129 130 public void setInitSqls(List<String> initSqls) { 131 this.initSqls = initSqls; 132 } 133 134 public boolean isCreateDataSource() { 135 return this.url != null && this.user != null; 136 } 137 138}