bug#AL-1726

correção da validação de ambiente dev na execução do flyway
master
Fabio Faria 2022-12-15 14:26:45 -03:00
parent 3f6e7192c3
commit 9fa68a40e1
2 changed files with 12 additions and 12 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.rjconsultores</groupId>
<artifactId>Flyway</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
<distributionManagement>
<repository>

View File

@ -146,7 +146,13 @@ public class FlyWay {
public boolean start(final String customLocation, final String customTable, Boolean isReloadFlyway) {
log.info("Executando Flyway...");
try{
try{
String ambiente = System.getProperty("ambiente") ==null || System.getProperty("ambiente").isEmpty() ? "" : System.getProperty("ambiente");
if( AMBIENTE_DEV.equalsIgnoreCase(ambiente) || AMBIENTE_CONSULTA.equalsIgnoreCase(ambiente) ) {
log.warn("Flyway não executado. Ambiente = dev ou consulta");
return true;
}
final Flyway flyway = new Flyway();
if (customTable != null) {
@ -166,22 +172,16 @@ public class FlyWay {
dataSource = flyway.getDataSource();
}
String ambiente = System.getProperty("ambiente") ==null || System.getProperty("ambiente").isEmpty() ? "" : System.getProperty("ambiente");
if(!AMBIENTE_DEV.equals(ambiente.toLowerCase()) || !AMBIENTE_CONSULTA.equals(ambiente.toLowerCase()) || Boolean.TRUE.equals(isReloadFlyway)) {
execute(flyway);
if(Boolean.TRUE.equals(isReloadFlyway)) {
execute(flyway);
log.info("Flyway executado.");
}else {
log.warn("Flyway não executado. Ambiente = dev");
}
}catch(Throwable t){
log.error("Erro ao executar o Flyway",t);
log.error("Erro ao executar o Flyway",t);
return false;
}
return true;
}