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-87c2c4800839master
parent
82f2272bf7
commit
400857c035
|
@ -70,6 +70,7 @@ public class FlyWay {
|
||||||
fixVersion(s, "20162410.1119", "20161024.1119", "V20161024_1119__mantis7904.sql");
|
fixVersion(s, "20162410.1119", "20161024.1119", "V20161024_1119__mantis7904.sql");
|
||||||
|
|
||||||
s.close();
|
s.close();
|
||||||
|
c.close();
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
|
@ -198,13 +199,24 @@ public class FlyWay {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connection c = null;
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Connection c = flyway.getDataSource().getConnection();
|
c = flyway.getDataSource().getConnection();
|
||||||
PreparedStatement ps = c.prepareStatement("update flyway_scripts set activo = 0 where nome like ?");
|
ps = c.prepareStatement("update flyway_scripts set activo = 0 where nome like ?");
|
||||||
ps.setString(1, errorCallback.getScriptError().replace(".sql", ""));
|
ps.setString(1, errorCallback.getScriptError().replace(".sql", ""));
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
|
|
||||||
} catch (SQLException e1) {
|
} 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());
|
ResultSet rs = s.executeQuery(sb.toString());
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
if (!isRegistroValido(rs.getString("nome_arquivo"), rs.getString("sql_arquivo"))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Timestamp timestamp = rs.getTimestamp("datahora");
|
Timestamp timestamp = rs.getTimestamp("datahora");
|
||||||
|
|
||||||
FlyWayCustomDetail detail = new FlyWayCustomDetail();
|
FlyWayCustomDetail detail = new FlyWayCustomDetail();
|
||||||
|
@ -258,6 +274,7 @@ public class FlyWay {
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
s.close();
|
s.close();
|
||||||
|
c.close();
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
|
@ -318,6 +335,44 @@ public class FlyWay {
|
||||||
return retorno;
|
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) {
|
private boolean existeSchema(Connection c) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("SELECT count(table_name) as existe FROM all_tables WHERE table_name = 'schema_version_cst'");
|
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();
|
rs.close();
|
||||||
s.close();
|
s.close();
|
||||||
|
c.close();
|
||||||
|
|
||||||
if (existe > 0) {
|
if (existe > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue