From a0fd5ad5da987789ba369054dd039f87369c6f2f Mon Sep 17 00:00:00 2001 From: Adrien Kantcheff <5028967+akantcheff@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:55:20 +0100 Subject: [PATCH] chore(MTR): remove tenantid from actor and actormember (#3296) Multi-tenancy removal Related to https://bonitasoft.atlassian.net/browse/BPM-347 --- .../engine/actor/mapping/model/SActor.java | 13 ++++++------- .../engine/actor/mapping/model/SActorMember.java | 13 ++++++------- .../src/main/resources/sql/h2/createTables.sql | 13 +++++++------ .../main/resources/sql/h2/postCreateStructure.sql | 3 --- .../main/resources/sql/postgres/createTables.sql | 13 +++++++------ .../resources/sql/postgres/postCreateStructure.sql | 3 --- 6 files changed, 26 insertions(+), 32 deletions(-) diff --git a/bpm/bonita-core/bonita-actor-mapping/src/main/java/org/bonitasoft/engine/actor/mapping/model/SActor.java b/bpm/bonita-core/bonita-actor-mapping/src/main/java/org/bonitasoft/engine/actor/mapping/model/SActor.java index c89f0e27f5b..09b7b4e0e5e 100644 --- a/bpm/bonita-core/bonita-actor-mapping/src/main/java/org/bonitasoft/engine/actor/mapping/model/SActor.java +++ b/bpm/bonita-core/bonita-actor-mapping/src/main/java/org/bonitasoft/engine/actor/mapping/model/SActor.java @@ -13,14 +13,16 @@ **/ package org.bonitasoft.engine.actor.mapping.model; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import org.bonitasoft.engine.persistence.PersistentObject; -import org.bonitasoft.engine.persistence.PersistentObjectId; +import org.bonitasoft.engine.persistence.PlatformPersistentObject; @Data @NoArgsConstructor @@ -28,11 +30,8 @@ @Builder @Entity @Table(name = "actor") -@IdClass(PersistentObjectId.class) -public class SActor implements PersistentObject { +public class SActor implements PlatformPersistentObject { - @Id - private long tenantId; @Id private long id; @Column diff --git a/bpm/bonita-core/bonita-actor-mapping/src/main/java/org/bonitasoft/engine/actor/mapping/model/SActorMember.java b/bpm/bonita-core/bonita-actor-mapping/src/main/java/org/bonitasoft/engine/actor/mapping/model/SActorMember.java index 2a2182765cc..f525138e135 100644 --- a/bpm/bonita-core/bonita-actor-mapping/src/main/java/org/bonitasoft/engine/actor/mapping/model/SActorMember.java +++ b/bpm/bonita-core/bonita-actor-mapping/src/main/java/org/bonitasoft/engine/actor/mapping/model/SActorMember.java @@ -13,22 +13,21 @@ **/ package org.bonitasoft.engine.actor.mapping.model; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; import lombok.Data; import lombok.NoArgsConstructor; -import org.bonitasoft.engine.persistence.PersistentObject; -import org.bonitasoft.engine.persistence.PersistentObjectId; +import org.bonitasoft.engine.persistence.PlatformPersistentObject; @Data @NoArgsConstructor @Entity @Table(name = "actormember") -@IdClass(PersistentObjectId.class) -public class SActorMember implements PersistentObject { +public class SActorMember implements PlatformPersistentObject { - @Id - private long tenantId; @Id private long id; @Column diff --git a/platform/platform-resources/src/main/resources/sql/h2/createTables.sql b/platform/platform-resources/src/main/resources/sql/h2/createTables.sql index 4accd32469f..8432ec15470 100644 --- a/platform/platform-resources/src/main/resources/sql/h2/createTables.sql +++ b/platform/platform-resources/src/main/resources/sql/h2/createTables.sql @@ -35,27 +35,28 @@ ALTER TABLE arch_contract_data ADD CONSTRAINT uc_acd_scope_name UNIQUE (kind, sc CREATE INDEX idx_acd_kind_scope_name ON arch_contract_data (kind, scopeId, name); CREATE TABLE actor ( - tenantid BIGINT NOT NULL, id BIGINT NOT NULL, scopeId BIGINT NOT NULL, name VARCHAR(50) NOT NULL, displayName VARCHAR(75), description TEXT, initiator BOOLEAN, - UNIQUE (tenantid, id, scopeId, name), - PRIMARY KEY (tenantid, id) + CONSTRAINT uk_actor_id_scopeid_name UNIQUE (id, scopeId, name), + CONSTRAINT pk_actor PRIMARY KEY (id) ); CREATE TABLE actormember ( - tenantid BIGINT NOT NULL, id BIGINT NOT NULL, actorId BIGINT NOT NULL, userId BIGINT NOT NULL, groupId BIGINT NOT NULL, roleId BIGINT NOT NULL, - UNIQUE (tenantid, actorid, userId, groupId, roleId), - PRIMARY KEY (tenantid, id) + CONSTRAINT uk_actormember_actorid_userid_groupid_roleid UNIQUE (actorId, userId, groupId, roleId), + CONSTRAINT pk_actormember PRIMARY KEY (id) ); + +ALTER TABLE actormember ADD CONSTRAINT fk_actormember_actorid FOREIGN KEY (actorId) REFERENCES actor(id); + CREATE TABLE category ( tenantid BIGINT NOT NULL, id BIGINT NOT NULL, diff --git a/platform/platform-resources/src/main/resources/sql/h2/postCreateStructure.sql b/platform/platform-resources/src/main/resources/sql/h2/postCreateStructure.sql index 2e600b47013..3211dc2e2a5 100644 --- a/platform/platform-resources/src/main/resources/sql/h2/postCreateStructure.sql +++ b/platform/platform-resources/src/main/resources/sql/h2/postCreateStructure.sql @@ -1,7 +1,4 @@ -- ------------------------------------------------ Foreign Keys ----------------------------------------------- -ALTER TABLE actor ADD CONSTRAINT fk_actor_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id); -ALTER TABLE actormember ADD CONSTRAINT fk_actormember_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id); -ALTER TABLE actormember ADD CONSTRAINT fk_actormember_actorId FOREIGN KEY (tenantid, actorId) REFERENCES actor(tenantid, id); ALTER TABLE category ADD CONSTRAINT fk_category_tenantId FOREIGN KEY (tenantid) REFERENCES tenant (id); ALTER TABLE command ADD CONSTRAINT fk_command_tenantId FOREIGN KEY (tenantid) REFERENCES tenant (id); ALTER TABLE connector_instance ADD CONSTRAINT fk_connector_instance_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id); diff --git a/platform/platform-resources/src/main/resources/sql/postgres/createTables.sql b/platform/platform-resources/src/main/resources/sql/postgres/createTables.sql index 4997d54678a..85b7c280ad2 100644 --- a/platform/platform-resources/src/main/resources/sql/postgres/createTables.sql +++ b/platform/platform-resources/src/main/resources/sql/postgres/createTables.sql @@ -37,27 +37,28 @@ ALTER TABLE arch_contract_data ADD CONSTRAINT uc_acd_scope_name UNIQUE (kind, sc CREATE INDEX idx_acd_kind_scope_name ON arch_contract_data (kind, scopeId, name); CREATE TABLE actor ( - tenantid INT8 NOT NULL, id INT8 NOT NULL, scopeId INT8 NOT NULL, name VARCHAR(50) NOT NULL, displayName VARCHAR(75), description TEXT, initiator BOOLEAN, - UNIQUE (tenantid, id, scopeId, name), - PRIMARY KEY (tenantid, id) + CONSTRAINT uk_actor_id_scopeid_name UNIQUE (id, scopeId, name), + CONSTRAINT pk_actor PRIMARY KEY (id) ); CREATE TABLE actormember ( - tenantid INT8 NOT NULL, id INT8 NOT NULL, actorId INT8 NOT NULL, userId INT8 NOT NULL, groupId INT8 NOT NULL, roleId INT8 NOT NULL, - UNIQUE (tenantid, actorid, userId, groupId, roleId), - PRIMARY KEY (tenantid, id) + CONSTRAINT uk_actormember_actorid_userid_groupid_roleid UNIQUE (actorId, userId, groupId, roleId), + CONSTRAINT pk_actormember PRIMARY KEY (id) ); + +ALTER TABLE actormember ADD CONSTRAINT fk_actormember_actorid FOREIGN KEY (actorId) REFERENCES actor(id); + CREATE TABLE category ( tenantid INT8 NOT NULL, id INT8 NOT NULL, diff --git a/platform/platform-resources/src/main/resources/sql/postgres/postCreateStructure.sql b/platform/platform-resources/src/main/resources/sql/postgres/postCreateStructure.sql index 9226c0f4a1f..dd3e967489d 100644 --- a/platform/platform-resources/src/main/resources/sql/postgres/postCreateStructure.sql +++ b/platform/platform-resources/src/main/resources/sql/postgres/postCreateStructure.sql @@ -1,7 +1,4 @@ -- ------------------------------------------------ Foreign Keys ----------------------------------------------- -ALTER TABLE actor ADD CONSTRAINT fk_actor_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id); -ALTER TABLE actormember ADD CONSTRAINT fk_actormember_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id); -ALTER TABLE actormember ADD CONSTRAINT fk_actormember_actorId FOREIGN KEY (tenantid, actorId) REFERENCES actor(tenantid, id); ALTER TABLE category ADD CONSTRAINT fk_category_tenantId FOREIGN KEY (tenantid) REFERENCES tenant (id); ALTER TABLE command ADD CONSTRAINT fk_command_tenantId FOREIGN KEY (tenantid) REFERENCES tenant (id); ALTER TABLE connector_instance ADD CONSTRAINT fk_connector_instance_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);