Nazar - Melhorias

bug#12464
dev:trevezani
qua:

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/BD/FlyWay/trunk@87693 d1611594-4594-4d17-8e1d-87c2c4800839
master
alberto 2018-12-05 19:19:47 +00:00
parent 82f2272bf7
commit 400857c035
1 changed files with 59 additions and 3 deletions

View File

@ -70,6 +70,7 @@ public class FlyWay {
fixVersion(s, "20162410.1119", "20161024.1119", "V20161024_1119__mantis7904.sql");
s.close();
c.close();
} catch (SQLException e) {
log.error(e.getMessage(), e);
@ -198,13 +199,24 @@ public class FlyWay {
}
}
Connection c = null;
PreparedStatement ps = null;
try {
Connection c = flyway.getDataSource().getConnection();
PreparedStatement ps = c.prepareStatement("update flyway_scripts set activo = 0 where nome like ?");
c = flyway.getDataSource().getConnection();
ps = c.prepareStatement("update flyway_scripts set activo = 0 where nome like ?");
ps.setString(1, errorCallback.getScriptError().replace(".sql", ""));
ps.executeUpdate();
} catch (SQLException e1) {
} finally {
if (ps != null) {
try { ps.close(); } catch (SQLException e1) {}
}
if (c != null) {
try { c.close(); } catch (SQLException e1) {}
}
}
}
@ -242,6 +254,10 @@ public class FlyWay {
ResultSet rs = s.executeQuery(sb.toString());
while (rs.next()) {
if (!isRegistroValido(rs.getString("nome_arquivo"), rs.getString("sql_arquivo"))) {
continue;
}
Timestamp timestamp = rs.getTimestamp("datahora");
FlyWayCustomDetail detail = new FlyWayCustomDetail();
@ -258,6 +274,7 @@ public class FlyWay {
rs.close();
s.close();
c.close();
} catch (SQLException e) {
log.error(e.getMessage(), e);
@ -318,6 +335,44 @@ public class FlyWay {
return retorno;
}
private boolean isRegistroValido(String versao, String sql) {
boolean valido = true;
String v[] = versao.split("_");
if (!versao.startsWith("V")) {
valido = false;
} else {
if (!(v.length == 4)) {
valido = false;
}
}
if (!valido) {
Connection c = null;
PreparedStatement ps = null;
try {
c = dataSource.getConnection();
ps = c.prepareStatement("update flyway_scripts set activo = 0 where nome like ?");
ps.setString(1, versao);
ps.executeUpdate();
} catch (SQLException e1) {
} finally {
if (ps != null) {
try { ps.close(); } catch (SQLException e1) {}
}
if (c != null) {
try { c.close(); } catch (SQLException e1) {}
}
}
}
return valido;
}
private boolean existeSchema(Connection c) {
StringBuilder sb = new StringBuilder();
sb.append("SELECT count(table_name) as existe FROM all_tables WHERE table_name = 'schema_version_cst'");
@ -334,6 +389,7 @@ public class FlyWay {
rs.close();
s.close();
c.close();
if (existe > 0) {
return true;