Exportação Fiscal : ECF e RMD (issue 8120)
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/BD/FlyWay/trunk@61890 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
128bb5d129
commit
393eaf31a8
|
@ -1,7 +1,13 @@
|
||||||
package com.rjconsultores.ventaboletos;
|
package com.rjconsultores.ventaboletos;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.flywaydb.core.Flyway;
|
import org.flywaydb.core.Flyway;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
public class FlyWay {
|
public class FlyWay {
|
||||||
|
@ -17,8 +23,48 @@ public class FlyWay {
|
||||||
|
|
||||||
public void defineDataSource(final DataSource dataSource) {
|
public void defineDataSource(final DataSource dataSource) {
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
|
|
||||||
|
fixFiles(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fixFiles(final DataSource ds) {
|
||||||
|
try {
|
||||||
|
Connection c = dataSource.getConnection();
|
||||||
|
Statement s = c.createStatement();
|
||||||
|
|
||||||
|
fixVersion(s, "20161910_0934", "20161019_0934", "V20161019_0934__mantis7907.sql");
|
||||||
|
fixVersion(s, "20162410.1119", "20161024.1119", "V20161024.1119__mantis7904.sql");
|
||||||
|
|
||||||
|
s.close();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fixVersion(final Statement s, final String oldVersion, final String newVersion, final String newScript) throws SQLException {
|
||||||
|
ResultSet rs = s.executeQuery("select count(*) as total from \"schema_version\" where \"version\" like '" + oldVersion + "'");
|
||||||
|
|
||||||
|
int total = 0;
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
total = rs.getInt("total");
|
||||||
|
}
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
|
||||||
|
if (total > 0) {
|
||||||
|
log.info("Fix version " + oldVersion + " to new version " + newVersion + " and new script " + newScript);
|
||||||
|
|
||||||
|
StringBuilder sql = new StringBuilder("");
|
||||||
|
sql.append(" update \"schema_version\"");
|
||||||
|
sql.append(" set \"version\" = '" + newVersion + "', \"script\" = '" + newScript + "'");
|
||||||
|
sql.append(" where \"version\" like '" + oldVersion + "'");
|
||||||
|
|
||||||
|
s.executeUpdate(sql.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
log.info("Executando Flyway...");
|
log.info("Executando Flyway...");
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
alter table fiscal_ml2 add (indvendamanual number(1));
|
||||||
|
|
||||||
|
update fiscal_ml2 set indvendamanual = 0;
|
||||||
|
|
||||||
|
update fiscal_ml2 set indvendamanual = 1 where fiscalml2_id in (
|
||||||
|
select ml2.fiscalml2_id
|
||||||
|
from fiscal_ml2 ml2
|
||||||
|
join boleto b on b.boleto_id = ml2.boleto_id
|
||||||
|
where b.tipoventa_id = 3);
|
||||||
|
|
||||||
|
alter table fiscal_r4 add (indvendamanual number(1));
|
||||||
|
|
||||||
|
update fiscal_r4 set indvendamanual = 0;
|
||||||
|
|
||||||
|
update fiscal_r4 set indvendamanual = 1 where fiscalr4_id in (
|
||||||
|
select r4.fiscalr4_id
|
||||||
|
from fiscal_r4 r4
|
||||||
|
join boleto b on b.boleto_id = r4.boleto_id
|
||||||
|
where b.tipoventa_id = 3);
|
Loading…
Reference in New Issue