Merge branch 'develop' into feature/JDK11
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -6,6 +6,7 @@ import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Migration_20250929172222 extends BaseMigration implements MigrationModelInterface {
|
||||
@@ -17,6 +18,37 @@ public class Migration_20250929172222 extends BaseMigration implements Migration
|
||||
|
||||
if (isCustomer(IntegryCustomer.Idrotecnica) || isCustomer(IntegryCustomer.Sabato) || isCustomer(IntegryCustomer.Ime) ||
|
||||
isCustomer(IntegryCustomer.Materica) || isCustomer(IntegryCustomer.Lippolis)) {
|
||||
|
||||
//Creo uno script SQL per cancellare e ricreare le FK che punteranno a stb_activity_old
|
||||
String fixFkSqlScript = "SELECT fk.name AS FK_Name,\n" +
|
||||
" OBJECT_NAME(fk.parent_object_id) AS FK_Table,\n" +
|
||||
" c1.name AS FK_Column,\n" +
|
||||
" OBJECT_NAME(fk.referenced_object_id) AS Ref_Table,\n" +
|
||||
" c2.name AS Ref_Column,\n" +
|
||||
" 'ALTER TABLE [' + OBJECT_NAME(fk.parent_object_id) +\n" +
|
||||
" '] DROP CONSTRAINT [' + fk.name + ']; ' +\n" +
|
||||
" 'ALTER TABLE [' + OBJECT_NAME(fk.parent_object_id) +\n" +
|
||||
" '] WITH CHECK ADD CONSTRAINT [' + fk.name +\n" +
|
||||
" '] FOREIGN KEY([' + c1.name +\n" +
|
||||
" ']) REFERENCES [dbo].[stb_activity]([' + c2.name + ']);' AS FixScript\n" +
|
||||
"FROM sys.foreign_keys fk\n" +
|
||||
" INNER JOIN sys.foreign_key_columns fkc ON fkc.constraint_object_id = fk.object_id\n" +
|
||||
" INNER JOIN sys.columns c1 ON fkc.parent_object_id = c1.object_id AND fkc.parent_column_id = c1.column_id\n" +
|
||||
" INNER JOIN sys.columns c2\n" +
|
||||
" ON fkc.referenced_object_id = c2.object_id AND fkc.referenced_column_id = c2.column_id\n" +
|
||||
"WHERE fk.referenced_object_id = OBJECT_ID('dbo.stb_activity');";
|
||||
|
||||
final List<HashMap<String, Object>> fixScriptResult = executeQuery(fixFkSqlScript);
|
||||
|
||||
String[] fixScripts = new String[0];
|
||||
|
||||
if (fixScriptResult != null && !fixScriptResult.isEmpty()) {
|
||||
fixScripts = fixScriptResult.stream()
|
||||
.map(x -> (String) x.get("FixScript"))
|
||||
.toArray(String[]::new);
|
||||
}
|
||||
|
||||
|
||||
executeStatement("CREATE TABLE dbo.stb_activity_new\n" +
|
||||
"(\n" +
|
||||
" activity_id VARCHAR(15) NOT NULL\n" +
|
||||
@@ -149,6 +181,8 @@ public class Migration_20250929172222 extends BaseMigration implements Migration
|
||||
"EXEC sp_rename 'dbo.stb_activity', 'stb_activity_old';",
|
||||
"EXEC sp_rename 'dbo.stb_activity_new', 'stb_activity';"
|
||||
);
|
||||
|
||||
executeStatement(fixScripts);
|
||||
}
|
||||
|
||||
dropIndex("stb_activity", "ix_stb_activity_raplav");
|
||||
|
||||
Reference in New Issue
Block a user