CREATE TABLE JBPM_ID_GROUP(ID_ BIGINT NOT NULL auto_increment,CLASS_ CHAR(1) NOT NULL,NAME_ VARCHAR(255),TYPE_ VARCHAR(255),PARENT_ BIGINT,primary key(ID_)) type=InnoDB;

alter table JBPM_ID_GROUP add index FK_ID_GRP_PARENT (PARENT_),add constraint FK_ID_GRP_PARENT foreign key (PARENT_) references JBPM_ID_GROUP(ID_);

CREATE  TABLE JBPM_ID_MEMBERSHIP(ID_ BIGINT NOT NULL auto_increment,CLASS_ CHAR(1) NOT NULL,NAME_ VARCHAR(255),ROLE_ VARCHAR(255),USER_ BIGINT,GROUP_ BIGINT,primary key(ID_)) type=InnoDB;

alter table JBPM_ID_MEMBERSHIP add index FK_ID_MEMSHIP_GRP (GROUP_),add constraint FK_ID_MEMSHIP_GRP foreign key (GROUP_) references JBPM_ID_GROUP(ID_);

CREATE TABLE JBPM_ID_PERMISSIONS(ENTITY_ BIGINT NOT NULL,CLASS_ VARCHAR(255),NAME_ VARCHAR(255),ACTION_ VARCHAR(255)) type=InnoDB;

ALTER TABLE JBPM_ID_MEMBERSHIP ADD index FK_ID_MEMSHIP_USR (USER_),add CONSTRAINT FK_ID_MEMSHIP_USR FOREIGN KEY(USER_) REFERENCES JBPM_ID_USER(ID_);

INSERT INTO JBPM_ID_GROUP VALUES(1,'G','sales','organisation',NULL);
INSERT INTO JBPM_ID_GROUP VALUES(2,'G','hr','organisation',NULL);
INSERT INTO JBPM_ID_GROUP VALUES(3,'G','participant','security-role',NULL);
INSERT INTO JBPM_ID_GROUP VALUES(4,'G','manager','security-role',NULL);
INSERT INTO JBPM_ID_GROUP VALUES(5,'G','administrator','security-role',NULL);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(1,'M',NULL,NULL,1,3);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(2,'M',NULL,NULL,2,3);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(3,'M',NULL,NULL,4,2);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(4,'M',NULL,NULL,4,3);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(5,'M',NULL,NULL,3,3);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(6,'M',NULL,NULL,3,2);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(7,'M',NULL,NULL,2,2);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(8,'M',NULL,NULL,2,4);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(9,'M',NULL,NULL,2,5);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(10,'M',NULL,'boss',2,1);
INSERT INTO JBPM_ID_MEMBERSHIP VALUES(11,'M',NULL,NULL,1,1);
