Skip to content

Commit

Permalink
Update oracle rac script
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaminduR committed Jan 24, 2024
1 parent 3856266 commit 2ce35f2
Showing 1 changed file with 104 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1910,6 +1910,106 @@ CREATE OR REPLACE TRIGGER IDN_ORG_USER_INVITE_ASSIGNMENT_TRIG
SELECT IDN_ORG_USER_INVITE_ASSIGNMENT_SEQ.nextval INTO :NEW.ID FROM dual;
END;
/
CREATE TABLE API_RESOURCE (
ID CHAR(36) NOT NULL PRIMARY KEY,
CURSOR_KEY INTEGER NOT NULL,
NAME VARCHAR(255) NOT NULL,
IDENTIFIER VARCHAR(255) NOT NULL,
TENANT_ID INT,
DESCRIPTION VARCHAR(255),
TYPE VARCHAR(255) NOT NULL,
REQUIRES_AUTHORIZATION NUMBER(1,0) NOT NULL
)
/
CREATE SEQUENCE API_RESOURCE_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER API_RESOURCE_TRIG
BEFORE INSERT
ON API_RESOURCE
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT API_RESOURCE_SEQ.nextval INTO :NEW.CURSOR_KEY FROM dual;
END;
/
CREATE TABLE API_RESOURCE_PROPERTY (
ID INTEGER,
API_ID CHAR(36) NOT NULL,
NAME VARCHAR(255) NOT NULL,
VALUE VARCHAR(255) NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT API_RESOURCE_PROPERTY_CONSTRAINT UNIQUE (API_ID, NAME),
FOREIGN KEY (API_ID) REFERENCES API_RESOURCE(ID) ON DELETE CASCADE
)
/
CREATE SEQUENCE API_RESOURCE_PROPERTY_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER API_RESOURCE_PROPERTY_TRIG
BEFORE INSERT
ON API_RESOURCE_PROPERTY
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT API_RESOURCE_PROPERTY_SEQ.nextval INTO :NEW.ID FROM dual;
END;
/
CREATE TABLE SCOPE (
ID CHAR(36) NOT NULL PRIMARY KEY,
CURSOR_KEY INTEGER NOT NULL,
API_ID CHAR(36) NOT NULL,
NAME VARCHAR(255) NOT NULL,
DISPLAY_NAME VARCHAR(255) NOT NULL,
TENANT_ID INT,
DESCRIPTION VARCHAR(300),
FOREIGN KEY (API_ID) REFERENCES API_RESOURCE(ID) ON DELETE CASCADE
)
/
CREATE SEQUENCE SCOPE_SEQ START WITH 1 INCREMENT BY 1 NOCACHE
/
CREATE OR REPLACE TRIGGER SCOPE_TRIG
BEFORE INSERT
ON SCOPE
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN
SELECT SCOPE_SEQ.nextval INTO :NEW.CURSOR_KEY FROM dual;
END;
/
CREATE TABLE APP_ROLE_ASSOCIATION (
APP_ID CHAR(36) NOT NULL,
ROLE_ID VARCHAR(255) NOT NULL,
PRIMARY KEY (APP_ID, ROLE_ID),
FOREIGN KEY (APP_ID) REFERENCES SP_APP(UUID) ON DELETE CASCADE
)
/
CREATE TABLE ROLE_SCOPE (
ROLE_ID VARCHAR(255) NOT NULL,
SCOPE_ID CHAR(36) NOT NULL,
PRIMARY KEY (ROLE_ID, SCOPE_ID),
FOREIGN KEY (SCOPE_ID) REFERENCES SCOPE(ID) ON DELETE CASCADE
)
/
CREATE TABLE AUTHORIZED_API (
APP_ID CHAR(36) NOT NULL,
API_ID CHAR(36) NOT NULL,
POLICY_ID VARCHAR(255) NOT NULL,
CONSTRAINT PK_APP_API PRIMARY KEY (APP_ID, API_ID),
FOREIGN KEY (API_ID) REFERENCES API_RESOURCE(ID) ON DELETE CASCADE,
FOREIGN KEY (APP_ID) REFERENCES SP_APP(UUID) ON DELETE CASCADE
)
/
CREATE TABLE AUTHORIZED_SCOPE (
APP_ID CHAR(36) NOT NULL,
API_ID CHAR(36) NOT NULL,
SCOPE_ID CHAR(36) NOT NULL,
CONSTRAINT PK_APP_API_SCOPE PRIMARY KEY (APP_ID, API_ID, SCOPE_ID),
FOREIGN KEY (API_ID) REFERENCES API_RESOURCE(ID),
FOREIGN KEY (SCOPE_ID) REFERENCES SCOPE(ID) ON DELETE CASCADE,
FOREIGN KEY (APP_ID) REFERENCES SP_APP(UUID),
FOREIGN KEY (APP_ID, API_ID) REFERENCES AUTHORIZED_API(APP_ID, API_ID) ON DELETE CASCADE,
CONSTRAINT AUTHORIZED_SCOPE_UNIQUE UNIQUE (APP_ID, SCOPE_ID)
)
/

-- --------------------------- INDEX CREATION -----------------------------
-- IDN_OAUTH2_ACCESS_TOKEN --
Expand Down Expand Up @@ -2050,3 +2150,7 @@ CREATE INDEX IDX_AUTH_PROP_AUTH_ID ON IDP_AUTHENTICATOR_PROPERTY (AUTHENTICATOR_
-- IDN_CONFIG_FILE --
CREATE INDEX IDX_CON_FILE_RES_ID ON IDN_CONFIG_FILE (RESOURCE_ID)
/

-- SCOPE --
CREATE INDEX API_ID_NAME_INDEX ON SCOPE (API_ID, NAME)
/

0 comments on commit 2ce35f2

Please sign in to comment.