Merge pull request 'bug#AL-1726' (#1) from AL-1726 into master

Reviewed-on: http://18.235.188.113:3000/utilidades/Flyway/pulls/1
Reviewed-by: Valdir Cordeiro <valdir.cordeiro@totvs.com.br>
Reviewed-by: Gleison da Cruz <gleison.cruz@totvs.com.br>
master
fabio 2022-12-16 13:26:19 +00:00
commit daebe66625
2 changed files with 13 additions and 14 deletions

View File

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

View File

@ -147,6 +147,12 @@ public class FlyWay {
log.info("Executando Flyway..."); 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)) && Boolean.FALSE.equals(isReloadFlyway) ) {
log.warn("Flyway não executado. Ambiente = dev ou consulta");
return true;
}
final Flyway flyway = new Flyway(); final Flyway flyway = new Flyway();
if (customTable != null) { if (customTable != null) {
@ -166,22 +172,15 @@ public class FlyWay {
dataSource = flyway.getDataSource(); 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);
log.info("Flyway executado.");
}else {
log.warn("Flyway não executado. Ambiente = dev");
}
execute(flyway);
log.info("Flyway executado.");
}catch(Throwable t){ }catch(Throwable t){
log.error("Erro ao executar o Flyway",t); log.error("Erro ao executar o Flyway",t);
return false; return false;
} }
return true; return true;
} }