diff --git a/openbas-api/src/main/java/io/openbas/migration/V3_54__Alter_xls_mapper_table.java b/openbas-api/src/main/java/io/openbas/migration/V3_54__Alter_xls_mapper_table.java new file mode 100644 index 0000000000..056bdd5eff --- /dev/null +++ b/openbas-api/src/main/java/io/openbas/migration/V3_54__Alter_xls_mapper_table.java @@ -0,0 +1,24 @@ +package io.openbas.migration; + +import java.sql.Connection; +import java.sql.Statement; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.springframework.stereotype.Component; + +@Component +public class V3_54__Alter_xls_mapper_table extends BaseJavaMigration { + + @Override + public void migrate(Context context) throws Exception { + Connection connection = context.getConnection(); + Statement statement = connection.createStatement(); + + statement.execute( + "ALTER TABLE inject_importers alter column importer_mapper_id drop not null;"); + statement.execute( + "ALTER TABLE inject_importers alter column importer_injector_contract_id drop not null;"); + statement.execute( + "ALTER TABLE rule_attributes alter column attribute_inject_importer_id drop not null;"); + } +} diff --git a/openbas-model/src/main/java/io/openbas/database/model/InjectImporter.java b/openbas-model/src/main/java/io/openbas/database/model/InjectImporter.java index 203d862d55..1de914e280 100644 --- a/openbas-model/src/main/java/io/openbas/database/model/InjectImporter.java +++ b/openbas-model/src/main/java/io/openbas/database/model/InjectImporter.java @@ -37,7 +37,7 @@ public class InjectImporter implements Base { @NotBlank private String importTypeValue; - @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) + @OneToOne @JoinColumn(name = "importer_injector_contract_id") @JsonProperty("inject_importer_injector_contract") @JsonSerialize(using = MonoIdDeserializer.class)