Skip to content

Commit

Permalink
feat(MTR): remove tenantid from message/event/trigger (#3323)
Browse files Browse the repository at this point in the history
Multi-tenancy removal for tables:
* event_trigger_instance
* waiting_event
* message_instance

relates to https://bonitasoft.atlassian.net/browse/BPM-347
  • Loading branch information
educhastenier authored Jan 20, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 8ec238d commit 68d2e73
Showing 10 changed files with 26 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -15,14 +15,14 @@

import lombok.Data;
import lombok.NoArgsConstructor;
import org.bonitasoft.engine.persistence.PersistentObject;
import org.bonitasoft.engine.persistence.PlatformPersistentObject;

/**
* @author Elias Ricken de Medeiros
*/
@Data
@NoArgsConstructor
public class SMessageEventCouple implements PersistentObject {
public class SMessageEventCouple implements PlatformPersistentObject {

private long waitingMessageId;
private SBPMEventType waitingMessageEventType;
@@ -44,10 +44,4 @@ public long getId() {
public void setId(final long id) {
throw new IllegalArgumentException();
}

@Override
public void setTenantId(final long id) {
throw new IllegalArgumentException();
}

}
Original file line number Diff line number Diff line change
@@ -13,27 +13,25 @@
**/
package org.bonitasoft.engine.core.process.instance.model.event.handling;

import javax.persistence.*;
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;

/**
* @author Elias Ricken de Medeiros
*/
@Data
@NoArgsConstructor
@Entity
@IdClass(PersistentObjectId.class)
@Table(name = "message_instance")
public class SMessageInstance implements PersistentObject {
public class SMessageInstance implements PlatformPersistentObject {

@Id
private long id;
@Id
private long tenantId;
private String messageName;
private String targetProcess;
private String targetFlowNode;
Original file line number Diff line number Diff line change
@@ -13,14 +13,18 @@
**/
package org.bonitasoft.engine.core.process.instance.model.event.handling;

import javax.persistence.*;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.bonitasoft.engine.core.process.definition.model.event.trigger.SEventTriggerType;
import org.bonitasoft.engine.persistence.PersistentObject;
import org.bonitasoft.engine.persistence.PersistentObjectId;
import org.bonitasoft.engine.persistence.PlatformPersistentObject;

/**
* @author Zhao Na
@@ -31,15 +35,12 @@
@NoArgsConstructor
@AllArgsConstructor
@Entity
@IdClass(PersistentObjectId.class)
@Table(name = "waiting_event")
@DiscriminatorColumn(name = "kind")
public abstract class SWaitingEvent implements PersistentObject {
public abstract class SWaitingEvent implements PlatformPersistentObject {

@Id
private long id;
@Id
private long tenantId;
@Enumerated(EnumType.STRING)
private SBPMEventType eventType;
private String processName;
Original file line number Diff line number Diff line change
@@ -13,29 +13,27 @@
**/
package org.bonitasoft.engine.core.process.instance.model.event.trigger;

import javax.persistence.*;
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;

/**
* @author Elias Ricken de Medeiros
*/
@Data
@NoArgsConstructor
@Entity
@IdClass(PersistentObjectId.class)
@Table(name = "event_trigger_instance")
public class STimerEventTriggerInstance implements PersistentObject {
public class STimerEventTriggerInstance implements PlatformPersistentObject {

public static final String EXECUTION_DATE = "executionDate";

@Id
private long id;
@Id
private long tenantId;
private long eventInstanceId;

/**
Original file line number Diff line number Diff line change
@@ -360,17 +360,15 @@ CREATE TABLE connector_instance (
CREATE INDEX idx_ci_container_activation ON connector_instance (containerId, containerType, activationEvent);

CREATE TABLE event_trigger_instance (
tenantid BIGINT NOT NULL,
id BIGINT NOT NULL,
eventInstanceId BIGINT NOT NULL,
eventInstanceName VARCHAR(50),
executionDate BIGINT,
jobTriggerName VARCHAR(255),
PRIMARY KEY (tenantid, id)
CONSTRAINT pk_event_trigger_instance PRIMARY KEY (id)
);

CREATE TABLE waiting_event (
tenantid BIGINT NOT NULL,
id BIGINT NOT NULL,
kind VARCHAR(15) NOT NULL,
eventType VARCHAR(50),
@@ -394,13 +392,12 @@ CREATE TABLE waiting_event (
correlation3 VARCHAR(128),
correlation4 VARCHAR(128),
correlation5 VARCHAR(128),
PRIMARY KEY (tenantid, id)
CONSTRAINT pk_waiting_event PRIMARY KEY (id)
);
CREATE INDEX idx_waiting_event ON waiting_event (progress, kind, locked, active);
CREATE INDEX idx_waiting_event_correl ON waiting_event (correlation1, correlation2, correlation3, correlation4, correlation5);

CREATE TABLE message_instance (
tenantid BIGINT NOT NULL,
id BIGINT NOT NULL,
messageName VARCHAR(255) NOT NULL,
targetProcess VARCHAR(255) NOT NULL,
@@ -415,7 +412,7 @@ CREATE TABLE message_instance (
correlation4 VARCHAR(128),
correlation5 VARCHAR(128),
creationDate BIGINT NOT NULL,
PRIMARY KEY (tenantid, id)
CONSTRAINT pk_message_instance PRIMARY KEY (id)
);
CREATE INDEX idx_message_instance ON message_instance (messageName, targetProcess, correlation1, correlation2, correlation3);
CREATE INDEX idx_message_instance_correl ON message_instance (correlation1, correlation2, correlation3, correlation4, correlation5);
Original file line number Diff line number Diff line change
@@ -5,14 +5,11 @@ ALTER TABLE data_instance ADD CONSTRAINT fk_data_instance_tenantId FOREIGN KEY (
ALTER TABLE document ADD CONSTRAINT fk_document_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);
ALTER TABLE document_mapping ADD CONSTRAINT fk_document_mapping_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);
ALTER TABLE document_mapping ADD CONSTRAINT fk_docmap_docid FOREIGN KEY (tenantid, documentid) REFERENCES document(tenantid, id) ON DELETE CASCADE;
ALTER TABLE event_trigger_instance ADD CONSTRAINT fk_event_trigger_instance_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);
ALTER TABLE message_instance ADD CONSTRAINT fk_message_instance_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);
ALTER TABLE pending_mapping ADD CONSTRAINT fk_pending_mapping_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);
ALTER TABLE pending_mapping ADD CONSTRAINT fk_pending_mapping_flownode_instanceId FOREIGN KEY (activityId) REFERENCES flownode_instance(id);
ALTER TABLE profilemember ADD CONSTRAINT fk_profilemember_tenantId FOREIGN KEY (tenantId) REFERENCES tenant(id);
ALTER TABLE multi_biz_data ADD CONSTRAINT fk_multi_biz_data_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);
ALTER TABLE ref_biz_data_inst ADD CONSTRAINT fk_ref_biz_data_inst_tenantId FOREIGN KEY (tenantId) REFERENCES tenant(id);
ALTER TABLE waiting_event ADD CONSTRAINT fk_waiting_event_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);

-- ------------------------ Foreign Keys to disable if archiving is on another BD ------------------
ALTER TABLE arch_document_mapping ADD CONSTRAINT fk_arch_document_mapping_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);
Original file line number Diff line number Diff line change
@@ -6,16 +6,13 @@ ALTER TABLE data_instance DROP CONSTRAINT fk_data_instance_tenantId;
ALTER TABLE document DROP CONSTRAINT fk_document_tenantId;
ALTER TABLE document_mapping DROP CONSTRAINT fk_document_mapping_tenantId;
ALTER TABLE document_mapping DROP CONSTRAINT fk_docmap_docid;
ALTER TABLE event_trigger_instance DROP CONSTRAINT fk_event_trigger_instance_tenantId;
ALTER TABLE message_instance DROP CONSTRAINT fk_message_instance_tenantId;
ALTER TABLE pending_mapping DROP CONSTRAINT fk_pending_mapping_tenantId;
ALTER TABLE pending_mapping DROP CONSTRAINT fk_pending_mapping_flownode_instanceId;
ALTER TABLE process_definition DROP CONSTRAINT fk_process_definition_content_id;
ALTER TABLE profile DROP CONSTRAINT fk_profile_tenantId;
ALTER TABLE profilemember DROP CONSTRAINT fk_profilemember_tenantId;
ALTER TABLE multi_biz_data DROP CONSTRAINT fk_multi_biz_data_tenantId;
ALTER TABLE ref_biz_data_inst DROP CONSTRAINT fk_ref_biz_data_inst_tenantId;
ALTER TABLE waiting_event DROP CONSTRAINT fk_waiting_event_tenantId;

ALTER TABLE profilemember DROP CONSTRAINT fk_profilemember_profileid;

Original file line number Diff line number Diff line change
@@ -360,17 +360,15 @@ CREATE TABLE connector_instance (
CREATE INDEX idx_ci_container_activation ON connector_instance (containerId, containerType, activationEvent);

CREATE TABLE event_trigger_instance (
tenantid INT8 NOT NULL,
id INT8 NOT NULL,
eventInstanceId INT8 NOT NULL,
eventInstanceName VARCHAR(50),
executionDate INT8,
jobTriggerName VARCHAR(255),
PRIMARY KEY (tenantid, id)
CONSTRAINT pk_event_trigger_instance PRIMARY KEY (id)
);

CREATE TABLE waiting_event (
tenantid INT8 NOT NULL,
id INT8 NOT NULL,
kind VARCHAR(15) NOT NULL,
eventType VARCHAR(50),
@@ -394,13 +392,12 @@ CREATE TABLE waiting_event (
correlation3 VARCHAR(128),
correlation4 VARCHAR(128),
correlation5 VARCHAR(128),
PRIMARY KEY (tenantid, id)
CONSTRAINT pk_waiting_event PRIMARY KEY (id)
);
CREATE INDEX idx_waiting_event ON waiting_event (progress, kind, locked, active);
CREATE INDEX idx_waiting_event_correl ON waiting_event (correlation1, correlation2, correlation3, correlation4, correlation5);

CREATE TABLE message_instance (
tenantid INT8 NOT NULL,
id INT8 NOT NULL,
messageName VARCHAR(255) NOT NULL,
targetProcess VARCHAR(255) NOT NULL,
@@ -415,7 +412,7 @@ CREATE TABLE message_instance (
correlation4 VARCHAR(128),
correlation5 VARCHAR(128),
creationDate INT8 NOT NULL,
PRIMARY KEY (tenantid, id)
CONSTRAINT pk_message_instance PRIMARY KEY (id)
);
CREATE INDEX idx_message_instance ON message_instance (messageName, targetProcess, correlation1, correlation2, correlation3);
CREATE INDEX idx_message_instance_correl ON message_instance (correlation1, correlation2, correlation3, correlation4, correlation5);
Original file line number Diff line number Diff line change
@@ -5,14 +5,11 @@ ALTER TABLE data_instance ADD CONSTRAINT fk_data_instance_tenantId FOREIGN KEY (
ALTER TABLE document ADD CONSTRAINT fk_document_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);
ALTER TABLE document_mapping ADD CONSTRAINT fk_document_mapping_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);
ALTER TABLE document_mapping ADD CONSTRAINT fk_docmap_docid FOREIGN KEY (tenantid, documentid) REFERENCES document(tenantid, id) ON DELETE CASCADE;
ALTER TABLE event_trigger_instance ADD CONSTRAINT fk_event_trigger_instance_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);
ALTER TABLE message_instance ADD CONSTRAINT fk_message_instance_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);
ALTER TABLE pending_mapping ADD CONSTRAINT fk_pending_mapping_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);
ALTER TABLE pending_mapping ADD CONSTRAINT fk_pending_mapping_flownode_instanceId FOREIGN KEY (activityId) REFERENCES flownode_instance(id);
ALTER TABLE profilemember ADD CONSTRAINT fk_profilemember_tenantId FOREIGN KEY (tenantId) REFERENCES tenant(id);
ALTER TABLE multi_biz_data ADD CONSTRAINT fk_multi_biz_data_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);
ALTER TABLE ref_biz_data_inst ADD CONSTRAINT fk_ref_biz_data_inst_tenantId FOREIGN KEY (tenantId) REFERENCES tenant(id);
ALTER TABLE waiting_event ADD CONSTRAINT fk_waiting_event_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);

-- ------------------------ Foreign Keys to disable if archiving is on another BD ------------------
ALTER TABLE arch_document_mapping ADD CONSTRAINT fk_arch_document_mapping_tenantId FOREIGN KEY (tenantid) REFERENCES tenant(id);
Original file line number Diff line number Diff line change
@@ -6,16 +6,13 @@ ALTER TABLE data_instance DROP CONSTRAINT fk_data_instance_tenantId;
ALTER TABLE document DROP CONSTRAINT fk_document_tenantId;
ALTER TABLE document_mapping DROP CONSTRAINT fk_document_mapping_tenantId;
ALTER TABLE document_mapping DROP CONSTRAINT fk_docmap_docid;
ALTER TABLE event_trigger_instance DROP CONSTRAINT fk_event_trigger_instance_tenantId;
ALTER TABLE message_instance DROP CONSTRAINT fk_message_instance_tenantId;
ALTER TABLE pending_mapping DROP CONSTRAINT fk_pending_mapping_tenantId;
ALTER TABLE pending_mapping DROP CONSTRAINT fk_pending_mapping_flownode_instanceId;
ALTER TABLE process_definition DROP CONSTRAINT fk_process_definition_content_id;
ALTER TABLE profile DROP CONSTRAINT fk_profile_tenantId;
ALTER TABLE profilemember DROP CONSTRAINT fk_profilemember_tenantId;
ALTER TABLE multi_biz_data DROP CONSTRAINT fk_multi_biz_data_tenantId;
ALTER TABLE ref_biz_data_inst DROP CONSTRAINT fk_ref_biz_data_inst_tenantId;
ALTER TABLE waiting_event DROP CONSTRAINT fk_waiting_event_tenantId;

ALTER TABLE profilemember DROP CONSTRAINT fk_profilemember_profileid;

0 comments on commit 68d2e73

Please sign in to comment.