Merge branch 'master' into develop
This commit is contained in:
@@ -145,6 +145,16 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
"ALTER TABLE " + tableName + " DROP COLUMN " + columnName);
|
||||
}
|
||||
|
||||
protected <T> void addDefault(String tableName, String columnName, T defaultValue) throws SQLException, IOException {
|
||||
boolean existDefault = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
||||
Query.format("SELECT CAST(COUNT(*) AS BIT)\n" +
|
||||
"FROM sys.syscolumns\n" +
|
||||
"WHERE name = %s\n" +
|
||||
" AND OBJECT_NAME(id) = %s\n" +
|
||||
" AND cdefault <> 0", columnName, tableName));
|
||||
if (!existDefault)
|
||||
executeStatement(Query.format("ALTER TABLE dbo." + tableName + " ADD DEFAULT (%s) FOR "+ columnName, defaultValue));
|
||||
}
|
||||
|
||||
protected boolean existsTable(String tableName) throws SQLException, IOException {
|
||||
String schema = null;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240322100900 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
addDefault("azienda", "flag_regime_speciale_iva", "N");
|
||||
executeStatement(
|
||||
"UPDATE azienda SET flag_regime_speciale_iva = 'N' WHERE flag_regime_speciale_iva is null ",
|
||||
"ALTER TABLE azienda ALTER COLUMN flag_regime_speciale_iva varchar(1) NOT NULL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -274,6 +274,9 @@ public class Azienda extends EntityBase {
|
||||
@SqlField(value = "mese_iniz_anno_fisc", nullable = false)
|
||||
private Integer meseInizAnnoFisc;
|
||||
|
||||
@SqlField(value = "flag_regime_speciale_iva", nullable = false, defaultObjectValue = "N")
|
||||
private String flagRegimeSpecialeIva;
|
||||
|
||||
@SqlField(value = "jwt_secret_key", maxLength = 8000, nullable = true)
|
||||
@JsonIgnore
|
||||
private String jwtSecretKey;
|
||||
@@ -283,20 +286,8 @@ public class Azienda extends EntityBase {
|
||||
}
|
||||
|
||||
public static boolean isDbInfragruppo(Connection conn) throws SQLException {
|
||||
String is_query = "SELECT count(*) FROM aziende_gruppo";
|
||||
int countAziende = 0;
|
||||
Statement cmd = conn.createStatement();
|
||||
ResultSet res = cmd.executeQuery(is_query);
|
||||
while (res.next()) {
|
||||
countAziende = res.getInt(1);
|
||||
}
|
||||
res.close();
|
||||
cmd.close();
|
||||
if (countAziende > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn,
|
||||
"SELECT Cast(count(*) as bit) FROM aziende_gruppo");
|
||||
}
|
||||
|
||||
public static HashMap<String, Object> getDatiAzienda(Connection conn) throws SQLException {
|
||||
@@ -944,6 +935,15 @@ public class Azienda extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFlagRegimeSpecialeIva() {
|
||||
return flagRegimeSpecialeIva;
|
||||
}
|
||||
|
||||
public Azienda setFlagRegimeSpecialeIva(String flagRegimeSpecialeIva) {
|
||||
this.flagRegimeSpecialeIva = flagRegimeSpecialeIva;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getJwtSecretKey() {
|
||||
return jwtSecretKey;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user