Skip to content

Commit

Permalink
Add Notification tables to all types of DBs
Browse files Browse the repository at this point in the history
  • Loading branch information
HelaniUdara committed May 2, 2024
1 parent 509b1c8 commit bd898f3
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3255,7 +3255,25 @@ CREATE TABLE AM_SUBJECT_ENTITY_REVOKED_EVENT
)
/

CREATE TABLE AM_NOTIFICATION (
NOTIFICATION_ID VARCHAR(64) NOT NULL UNIQUE,
NOTIFICATION_TYPE VARCHAR(50) NOT NULL,
CREATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
NOTIFICATION_METADATA BLOB DEFAULT NULL,
PRIMARY KEY (NOTIFICATION_ID)
)
/

CREATE TABLE AM_NOTIFICATION_END_USERS (
NOTIFICATION_ID VARCHAR(64) NOT NULL,
DESTINATION_USER VARCHAR(255) NOT NULL,
ORGANIZATION VARCHAR(100) NOT NULL,
IS_READ BOOLEAN DEFAULT FALSE,
PORTAL_TO_DISPLAY VARCHAR(64) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID, DESTINATION_USER, ORGANIZATION, PORTAL_TO_DISPLAY),
FOREIGN KEY (NOTIFICATION_ID) REFERENCES AM_NOTIFICATION(NOTIFICATION_ID) ON DELETE CASCADE
)
/



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2449,7 +2449,6 @@ CREATE TABLE IF NOT EXISTS AM_SUBJECT_ENTITY_REVOKED_EVENT (
PRIMARY KEY (ENTITY_ID, ENTITY_TYPE, ORGANIZATION)
);


CREATE TABLE IF NOT EXISTS AM_NOTIFICATION (
NOTIFICATION_ID VARCHAR(64) NOT NULL UNIQUE,
NOTIFICATION_TYPE VARCHAR(50) NOT NULL,
Expand All @@ -2468,8 +2467,6 @@ CREATE TABLE IF NOT EXISTS AM_NOTIFICATION_END_USERS (
FOREIGN KEY (NOTIFICATION_ID) REFERENCES AM_NOTIFICATION(NOTIFICATION_ID) ON DELETE CASCADE
);



-- End of API-MGT Tables --

-- Index creation for APIM Tables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2718,6 +2718,26 @@ CREATE TABLE AM_SUBJECT_ENTITY_REVOKED_EVENT (
PRIMARY KEY (ENTITY_ID, ENTITY_TYPE, ORGANIZATION)
);

IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_NOTIFICATION]') AND TYPE IN (N'U'))
CREATE TABLE AM_NOTIFICATION (
NOTIFICATION_ID VARCHAR(64) NOT NULL UNIQUE,
NOTIFICATION_TYPE VARCHAR(50) NOT NULL,
CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP,
NOTIFICATION_METADATA VARBINARY(MAX) DEFAULT NULL,
PRIMARY KEY (NOTIFICATION_ID)
);

IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_NOTIFICATION_END_USERS]') AND TYPE IN (N'U'))
CREATE TABLE AM_NOTIFICATION_END_USERS (
NOTIFICATION_ID VARCHAR(64) NOT NULL,
DESTINATION_USER VARCHAR(255) NOT NULL,
ORGANIZATION VARCHAR(100) NOT NULL,
IS_READ BIT DEFAULT 0,
PORTAL_TO_DISPLAY VARCHAR(64) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID, DESTINATION_USER, ORGANIZATION, PORTAL_TO_DISPLAY),
FOREIGN KEY (NOTIFICATION_ID) REFERENCES AM_NOTIFICATION(NOTIFICATION_ID) ON DELETE CASCADE
);

--Performance indexes start--

create index IDX_ITS_LMT on IDN_THRIFT_SESSION (LAST_MODIFIED_TIME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2473,6 +2473,24 @@ CREATE TABLE IF NOT EXISTS AM_SUBJECT_ENTITY_REVOKED_EVENT (
PRIMARY KEY (ENTITY_ID, ENTITY_TYPE, ORGANIZATION)
)ENGINE INNODB;

CREATE TABLE IF NOT EXISTS AM_NOTIFICATION (
NOTIFICATION_ID VARCHAR(64) NOT NULL UNIQUE,
NOTIFICATION_TYPE VARCHAR(50) NOT NULL,
CREATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
NOTIFICATION_METADATA BLOB DEFAULT NULL,
PRIMARY KEY (NOTIFICATION_ID)
)ENGINE INNODB;

CREATE TABLE IF NOT EXISTS AM_NOTIFICATION_END_USERS (
NOTIFICATION_ID VARCHAR(64) NOT NULL,
DESTINATION_USER VARCHAR(255) NOT NULL,
ORGANIZATION VARCHAR(100) NOT NULL,
IS_READ BOOLEAN DEFAULT FALSE,
PORTAL_TO_DISPLAY VARCHAR(64) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID, DESTINATION_USER, ORGANIZATION, PORTAL_TO_DISPLAY),
FOREIGN KEY (NOTIFICATION_ID) REFERENCES AM_NOTIFICATION(NOTIFICATION_ID) ON DELETE CASCADE
)ENGINE INNODB;



-- Performance indexes start--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2646,7 +2646,23 @@ CREATE TABLE IF NOT EXISTS AM_SUBJECT_ENTITY_REVOKED_EVENT (
PRIMARY KEY (ENTITY_ID, ENTITY_TYPE, ORGANIZATION)
)ENGINE=NDB;

CREATE TABLE IF NOT EXISTS AM_NOTIFICATION (
NOTIFICATION_ID VARCHAR(64) NOT NULL UNIQUE,
NOTIFICATION_TYPE VARCHAR(50) NOT NULL,
CREATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
NOTIFICATION_METADATA BLOB DEFAULT NULL,
PRIMARY KEY (NOTIFICATION_ID)
)ENGINE=NDB;

CREATE TABLE IF NOT EXISTS AM_NOTIFICATION_END_USERS (
NOTIFICATION_ID VARCHAR(64) NOT NULL,
DESTINATION_USER VARCHAR(255) NOT NULL,
ORGANIZATION VARCHAR(100) NOT NULL,
IS_READ BOOLEAN DEFAULT 0,
PORTAL_TO_DISPLAY VARCHAR(64) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID, DESTINATION_USER, ORGANIZATION, PORTAL_TO_DISPLAY),
FOREIGN KEY (NOTIFICATION_ID) REFERENCES AM_NOTIFICATION(NOTIFICATION_ID) ON DELETE CASCADE
)ENGINE=NDB;

-- End of API-MGT Tables --

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3835,8 +3835,25 @@ CREATE TABLE AM_SUBJECT_ENTITY_REVOKED_EVENT
)
/

CREATE TABLE AM_NOTIFICATION (
NOTIFICATION_ID VARCHAR(64) NOT NULL UNIQUE,
NOTIFICATION_TYPE VARCHAR(50) NOT NULL,
CREATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
NOTIFICATION_METADATA BLOB DEFAULT NULL,
PRIMARY KEY (NOTIFICATION_ID)
)
/


CREATE TABLE AM_NOTIFICATION_END_USERS (
NOTIFICATION_ID VARCHAR(64) NOT NULL,
DESTINATION_USER VARCHAR(255) NOT NULL,
ORGANIZATION VARCHAR(100) NOT NULL,
IS_READ CHAR(1) DEFAULT 0,
PORTAL_TO_DISPLAY VARCHAR(64) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID, DESTINATION_USER, ORGANIZATION, PORTAL_TO_DISPLAY),
FOREIGN KEY (NOTIFICATION_ID) REFERENCES AM_NOTIFICATION(NOTIFICATION_ID) ON DELETE CASCADE
)
/

-- End of API-MGT Tables --

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3835,7 +3835,25 @@ CREATE TABLE AM_SUBJECT_ENTITY_REVOKED_EVENT
)
/

CREATE TABLE AM_NOTIFICATION (
NOTIFICATION_ID VARCHAR(64) NOT NULL UNIQUE,
NOTIFICATION_TYPE VARCHAR(50) NOT NULL,
CREATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
NOTIFICATION_METADATA BLOB DEFAULT NULL,
PRIMARY KEY (NOTIFICATION_ID)
)
/

CREATE TABLE AM_NOTIFICATION_END_USERS (
NOTIFICATION_ID VARCHAR(64) NOT NULL,
DESTINATION_USER VARCHAR(255) NOT NULL,
ORGANIZATION VARCHAR(100) NOT NULL,
IS_READ BOOLEAN DEFAULT FALSE,
PORTAL_TO_DISPLAY VARCHAR(64) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID, DESTINATION_USER, ORGANIZATION, PORTAL_TO_DISPLAY),
FOREIGN KEY (NOTIFICATION_ID) REFERENCES AM_NOTIFICATION(NOTIFICATION_ID) ON DELETE CASCADE
)
/


-- End of API-MGT Tables --
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3806,6 +3806,25 @@ CREATE TABLE AM_SUBJECT_ENTITY_REVOKED_EVENT
)
/

CREATE TABLE AM_NOTIFICATION (
NOTIFICATION_ID VARCHAR(64) NOT NULL UNIQUE,
NOTIFICATION_TYPE VARCHAR(50) NOT NULL,
CREATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
NOTIFICATION_METADATA BLOB DEFAULT NULL,
PRIMARY KEY (NOTIFICATION_ID)
)
/

CREATE TABLE AM_NOTIFICATION_END_USERS (
NOTIFICATION_ID VARCHAR(64) NOT NULL,
DESTINATION_USER VARCHAR(255) NOT NULL,
ORGANIZATION VARCHAR(100) NOT NULL,
IS_READ CHAR(1) DEFAULT 0,
PORTAL_TO_DISPLAY VARCHAR(64) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID, DESTINATION_USER, ORGANIZATION, PORTAL_TO_DISPLAY),
FOREIGN KEY (NOTIFICATION_ID) REFERENCES AM_NOTIFICATION(NOTIFICATION_ID) ON DELETE CASCADE
)
/

-- End of API-MGT Tables --

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2822,6 +2822,26 @@ CREATE TABLE IF NOT EXISTS AM_SUBJECT_ENTITY_REVOKED_EVENT (
PRIMARY KEY (ENTITY_ID, ENTITY_TYPE, ORGANIZATION)
);

DROP TABLE IF EXISTS AM_NOTIFICATION;
CREATE TABLE IF NOT EXISTS AM_NOTIFICATION (
NOTIFICATION_ID VARCHAR(64) NOT NULL UNIQUE,
NOTIFICATION_TYPE VARCHAR(50) NOT NULL,
CREATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
NOTIFICATION_METADATA BYTEA DEFAULT NULL,
PRIMARY KEY (NOTIFICATION_ID)
);

DROP TABLE IF EXISTS AM_NOTIFICATION_END_USERS;
CREATE TABLE IF NOT EXISTS AM_NOTIFICATION_END_USERS (
NOTIFICATION_ID VARCHAR(64) NOT NULL,
DESTINATION_USER VARCHAR(255) NOT NULL,
ORGANIZATION VARCHAR(100) NOT NULL,
IS_READ BOOLEAN DEFAULT FALSE,
PORTAL_TO_DISPLAY VARCHAR(64) NOT NULL,
PRIMARY KEY (NOTIFICATION_ID, DESTINATION_USER, ORGANIZATION, PORTAL_TO_DISPLAY),
FOREIGN KEY (NOTIFICATION_ID) REFERENCES AM_NOTIFICATION(NOTIFICATION_ID) ON DELETE CASCADE
);


-- End of API-MGT Tables --

Expand Down

0 comments on commit bd898f3

Please sign in to comment.