Skip to content

Commit aa8a081

Browse files
committed
major change
1 parent 642f886 commit aa8a081

File tree

17 files changed

+875
-1088
lines changed

17 files changed

+875
-1088
lines changed

database/install/data/001.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
-- CREATE DATA
2+
3+
-- create systemAdmin person
4+
25
INSERT INTO account (ID, ACCOUNT_NAME, CREATED, MODIFIED, CREATED_BY_ID, CONTACT_ID) VALUES
36
(1, 'systemAdmin', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, NULL);
47

@@ -7,4 +10,3 @@ INSERT INTO person (ID, ACCOUNT_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME, DOB, GEN
710

811
INSERT INTO login_details (ID, PERSON_ID, LOGIN_NAME, PASSWORD, STATUS) VALUES
912
(1, 1, 'systemAdmin', '1187f64663b88f692f23dbe47723908020', 'ACTIVE');
10-

database/install/schema/001.sql

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22
-- Drop Tables
33

4-
DROP TABLE IF EXISTS groups_accounts;
5-
DROP TABLE IF EXISTS groups;
4+
65
DROP TABLE IF EXISTS organization_person;
76
DROP TABLE IF EXISTS organization;
87
DROP TABLE IF EXISTS login_history;
98
DROP TABLE IF EXISTS login_details;
109
DROP TABLE IF EXISTS person_role;
1110
DROP TABLE IF EXISTS person;
11+
DROP TABLE IF EXISTS composed_roles;
1212
DROP TABLE IF EXISTS role;
1313
DROP TABLE IF EXISTS account;
1414
DROP TABLE IF EXISTS contact;
@@ -32,6 +32,11 @@ CREATE TABLE account
3232
);
3333

3434

35+
CREATE TABLE composed_roles
36+
(
37+
ROLE_ID bigint(10) unsigned NOT NULL,
38+
COMPOSED_ROLE_ID bigint(10) unsigned NOT NULL
39+
);
3540
CREATE TABLE contact
3641
(
3742
ID bigint(10) unsigned NOT NULL AUTO_INCREMENT,
@@ -41,23 +46,6 @@ Application modules can decide on the schema of this json object',
4146
);
4247

4348

44-
CREATE TABLE groups
45-
(
46-
ID bigint(10) unsigned NOT NULL AUTO_INCREMENT,
47-
ACCOUNT_ID bigint(10) unsigned NOT NULL,
48-
NAME varchar(20),
49-
PRIMARY KEY (ID),
50-
UNIQUE (ACCOUNT_ID)
51-
);
52-
53-
54-
CREATE TABLE groups_accounts
55-
(
56-
GROUP_ID bigint(10) unsigned NOT NULL,
57-
ACCOUNT_ID bigint(10) unsigned NOT NULL,
58-
ACCOUNT_TYPE enum('ORGANIZATION','PERSON','GROUPS','ROLE') NOT NULL,
59-
UNIQUE (GROUP_ID, ACCOUNT_ID)
60-
);
6149

6250

6351
CREATE TABLE login_details
@@ -101,6 +89,7 @@ CREATE TABLE organization_person
10189
(
10290
ORGANIZATION_ID bigint(10) unsigned NOT NULL,
10391
PERSON_ID bigint(10) unsigned NOT NULL,
92+
TYPE enum('OWNER','ADMINISTRATOR','MEMBER') DEFAULT 'MEMBER' NOT NULL,
10493
UNIQUE (ORGANIZATION_ID, PERSON_ID)
10594
);
10695

@@ -155,27 +144,6 @@ ALTER TABLE account
155144
ON DELETE SET NULL
156145
;
157146

158-
ALTER TABLE groups
159-
ADD FOREIGN KEY (ACCOUNT_ID)
160-
REFERENCES account (ID)
161-
ON UPDATE CASCADE
162-
ON DELETE RESTRICT
163-
;
164-
165-
ALTER TABLE groups_accounts
166-
ADD FOREIGN KEY (ACCOUNT_ID)
167-
REFERENCES account (ID)
168-
ON UPDATE CASCADE
169-
ON DELETE CASCADE
170-
;
171-
172-
ALTER TABLE groups_accounts
173-
ADD FOREIGN KEY (GROUP_ID)
174-
REFERENCES groups (ID)
175-
ON UPDATE CASCADE
176-
ON DELETE RESTRICT
177-
;
178-
179147
ALTER TABLE organization
180148
ADD FOREIGN KEY (ACCOUNT_ID)
181149
REFERENCES account (ID)
@@ -244,6 +212,20 @@ ALTER TABLE person_role
244212
ON DELETE CASCADE
245213
;
246214

215+
ALTER TABLE composed_roles
216+
ADD FOREIGN KEY (ROLE_ID)
217+
REFERENCES ROLE (ID)
218+
ON UPDATE RESTRICT
219+
ON DELETE RESTRICT
220+
;
221+
222+
223+
ALTER TABLE composed_roles
224+
ADD FOREIGN KEY (COMPOSED_ROLE_ID)
225+
REFERENCES ROLE (ID)
226+
ON UPDATE CASCADE
227+
ON DELETE CASCADE
228+
;
247229
ALTER TABLE person_role
248230
ADD FOREIGN KEY (ROLE_ID)
249231
REFERENCES role (ID)

0 commit comments

Comments
 (0)