Fixed issues in APPM DB scripts.

4.x.x
Harshan Liyanage 8 years ago
parent 6abd289cc6
commit 36d82c85ef

@ -1,44 +1,287 @@
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_TYPE ( -- -----------------------------------------------------
ID INTEGER AUTO_INCREMENT, -- Schema WSO2DM_APPM_DB
NAME VARCHAR (255), -- -----------------------------------------------------
DESCRIPTION TEXT,
CODE VARCHAR (255),
PARAMTERS LONGTEXT,
PRIMARY KEY (ID)
);
-- -----------------------------------------------------
-- Table APPM_PLATFORM
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_PLATFORM (
ID INT NOT NULL,
NAME VARCHAR(100) NOT NULL,
DESCRIPTION TEXT NULL,
IDENTIFIER VARCHAR(100) NOT NULL,
ICON_NAME VARCHAR(100) NULL,
DESCRIPTOR LONGTEXT NOT NULL,
PUBLISHED TINYINT NULL,
PRIMARY KEY (ID),
UNIQUE INDEX IDENTIFIER_UNIQUE (IDENTIFIER ASC));
-- -----------------------------------------------------
-- Table APPM_APPLICATION_CATEGORY
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_CATEGORY ( CREATE TABLE IF NOT EXISTS APPM_APPLICATION_CATEGORY (
ID INTEGER AUTO_INCREMENT, ID INT NOT NULL AUTO_INCREMENT,
NAME VARCHAR (255), NAME VARCHAR(100) NOT NULL,
DESCRIPTION TEXT, DESCRIPTION TEXT NULL,
PRIMARY KEY (ID) PUBLISHED TINYINT NULL,
); PRIMARY KEY (ID));
-- -----------------------------------------------------
-- Table APPM_PLATFORM_APPLICATION_MAPPING
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_PLATFORM_APPLICATION_MAPPING (
ID INT NOT NULL AUTO_INCREMENT,
PLATFORM_ID INT NOT NULL,
TENANT_ID INT NOT NULL,
PRIMARY KEY (ID, PLATFORM_ID),
CONSTRAINT fk_APPM_PLATFORM_TENANT_MAPPING_APPM_SUPPORTED_PLATFORM1
FOREIGN KEY (PLATFORM_ID)
REFERENCES APPM_PLATFORM (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE INDEX FK_PLATFROM_APPLICATION_MAPPING_PLATFORM ON APPM_PLATFORM_APPLICATION_MAPPING(PLATFORM_ID ASC);
-- -----------------------------------------------------
-- Table APPM_APPLICATION
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_APPLICATION ( CREATE TABLE IF NOT EXISTS APPM_APPLICATION (
ID INTEGER AUTO_INCREMENT, ID INT NOT NULL AUTO_INCREMENT,
NAME VARCHAR (255), UUID VARCHAR(100) NOT NULL,
UUID VARCHAR (255), NAME VARCHAR(100) NOT NULL,
DESCRIPTION MEDIUMTEXT, SHORT_DESCRIPTION VARCHAR(255) NULL,
ICON_NAME VARCHAR (255), DESCRIPTION TEXT NULL,
BANNER_NAME VARCHAR (255), ICON_NAME VARCHAR(100) NULL,
VIDEO_NAME VARCHAR (255), BANNER_NAME VARCHAR(100) NULL,
SCREENSHOTS TEXT, VIDEO_NAME VARCHAR(100) NULL,
TAGS TEXT, SCREENSHOTS TEXT NULL,
APPLICATION_TYPE_ID INTEGER, CREATED_BY VARCHAR(255) NULL,
CATEGORY_ID INTEGER, CREATED_AT DATETIME NOT NULL,
CREATED_AT DATETIME, MODIFIED_AT DATETIME NULL,
MODIFIED_AT DATETIME, PUBLISHED TINYINT NULL,
PRIMARY KEY (ID), APPLICATION_CATEGORY_ID INT NOT NULL,
FOREIGN KEY (CATEGORY_ID) REFERENCES APPM_APPLICATION_CATEGORY(ID), PLATFORM_APPLICATION_MAPPING_ID INT NOT NULL,
FOREIGN KEY (APPLICATION_TYPE_ID) REFERENCES APPM_APPLICATION_TYPE(ID) PRIMARY KEY (ID, APPLICATION_CATEGORY_ID, PLATFORM_APPLICATION_MAPPING_ID),
); UNIQUE INDEX UUID_UNIQUE (UUID ASC),
CONSTRAINT FK_APPLICATION_APPLICATION_CATEGORY
FOREIGN KEY (APPLICATION_CATEGORY_ID)
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_PROPERTIES ( REFERENCES APPM_APPLICATION_CATEGORY (ID)
PROP_KEY VARCHAR (255), ON DELETE NO ACTION
PROP_VAL MEDIUMTEXT, ON UPDATE NO ACTION,
APPLICATION_ID INTEGER, CONSTRAINT fk_APPM_APPLICATION_APPM_PLATFORM_APPLICATION_MAPPING1
PRIMARY KEY (APPLICATION_ID, PROP_KEY), FOREIGN KEY (PLATFORM_APPLICATION_MAPPING_ID)
FOREIGN KEY (APPLICATION_ID) REFERENCES APPM_APPLICATION(ID) REFERENCES APPM_PLATFORM_APPLICATION_MAPPING (ID)
); ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE INDEX FK_APPLICATION_APPLICATION_CATEGORY ON APPM_APPLICATION(APPLICATION_CATEGORY_ID ASC);
CREATE INDEX FK_APPLICATION_PLATFORM_APPLICATION_MAPPING ON APPM_APPLICATION(PLATFORM_APPLICATION_MAPPING_ID ASC);
-- -----------------------------------------------------
-- Table APPM_APPLICATION_PROPERTY
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_PROPERTY (
PROP_KEY VARCHAR(255) NOT NULL,
PROP_VAL TEXT NULL,
APPLICATION_ID INT NOT NULL,
PRIMARY KEY (PROP_KEY, APPLICATION_ID),
CONSTRAINT FK_APPLICATION_PROPERTY_APPLICATION
FOREIGN KEY (APPLICATION_ID)
REFERENCES APPM_APPLICATION (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE INDEX FK_APPLICATION_PROPERTY_APPLICATION ON APPM_APPLICATION_PROPERTY(APPLICATION_ID ASC);
-- -----------------------------------------------------
-- Table APPM_LIFECYCLE_STATE
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_LIFECYCLE_STATE (
ID INT NOT NULL AUTO_INCREMENT,
NAME VARCHAR(100) NOT NULL,
IDENTIFIER VARCHAR(100) NOT NULL,
DESCRIPTION TEXT NULL,
PRIMARY KEY (ID),
UNIQUE INDEX IDENTIFIER_UNIQUE1 (IDENTIFIER ASC));
-- -----------------------------------------------------
-- Table APPM_APPLICATION_RELEASE
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_RELEASE (
ID INT NOT NULL AUTO_INCREMENT,
VERSION_ID INT NOT NULL,
VERSION_NAME VARCHAR(100) NOT NULL,
RESOURCE TEXT NULL,
RELEASE_CHANNEL VARCHAR(50) NULL,
RELEASE_DETAILS TEXT NULL,
CREATED_AT DATETIME NOT NULL,
APPM_APPLICATION_ID INT NOT NULL,
APPM_LIFECYCLE_STATE_ID INT NOT NULL,
LIECYCLE_STATE_MODIFIED_BY VARCHAR(45) NULL,
LIFECYCLE_STATE_MODIFIED_AT DATETIME NULL,
PRIMARY KEY (ID, APPM_APPLICATION_ID, APPM_LIFECYCLE_STATE_ID),
CONSTRAINT FK_APPLICATION_VERSION_APPLICATION
FOREIGN KEY (APPM_APPLICATION_ID)
REFERENCES APPM_APPLICATION (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT fk_APPM_APPLICATION_RELEASE_APPM_LIFECYCLE_STATE1
FOREIGN KEY (APPM_LIFECYCLE_STATE_ID)
REFERENCES APPM_LIFECYCLE_STATE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE INDEX FK_APPLICATION_VERSION_APPLICATION ON APPM_APPLICATION_RELEASE(APPM_APPLICATION_ID ASC);
CREATE INDEX FK_APPLICATION_RELEASE_APPM_LIFECYCLE_STATE ON APPM_APPLICATION_RELEASE(APPM_LIFECYCLE_STATE_ID ASC);
-- -----------------------------------------------------
-- Table APPM_RELEASE_PROPERTY
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_RELEASE_PROPERTY (
PROP_KEY VARCHAR(255) NOT NULL,
PROP_VALUE TEXT NULL,
APPLICATION_RELEASE_ID INT NOT NULL,
PRIMARY KEY (PROP_KEY, APPLICATION_RELEASE_ID),
CONSTRAINT FK_RELEASE_PROPERTY_APPLICATION_RELEASE
FOREIGN KEY (APPLICATION_RELEASE_ID)
REFERENCES APPM_APPLICATION_RELEASE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE INDEX FK_RELEASE_PROPERTY_APPLICATION_RELEASE ON APPM_RELEASE_PROPERTY(APPLICATION_RELEASE_ID ASC);
-- -----------------------------------------------------
-- Table APPM_RESOURCE_TYPE
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_RESOURCE_TYPE (
ID INT NOT NULL AUTO_INCREMENT,
NAME VARCHAR(45) NULL,
DESCRIPTION TEXT NULL,
PRIMARY KEY (ID));
-- -----------------------------------------------------
-- Table APPM_SUBSCRIPTION
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_SUBSCRIPTION (
ID INT NOT NULL AUTO_INCREMENT,
VALUE VARCHAR(255) NOT NULL,
CREATED_AT DATETIME NOT NULL,
RESOURCE_TYPE_ID INT NOT NULL,
APPLICATION_ID INT NOT NULL,
APPLICATION_RELEASE_ID INT NULL,
PRIMARY KEY (ID, APPLICATION_ID, RESOURCE_TYPE_ID),
CONSTRAINT fk_APPM_APPLICATION_SUBSCRIPTION_APPM_RESOURCE_TYPE1
FOREIGN KEY (RESOURCE_TYPE_ID)
REFERENCES APPM_RESOURCE_TYPE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT fk_APPM_APPLICATION_SUBSCRIPTION_APPM_APPLICATION1
FOREIGN KEY (APPLICATION_ID)
REFERENCES APPM_APPLICATION (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT fk_APPM_APPLICATION_SUBSCRIPTION_APPM_APPLICATION_RELEASE1
FOREIGN KEY (APPLICATION_RELEASE_ID)
REFERENCES APPM_APPLICATION_RELEASE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE INDEX FK_APPLICATION_SUBSCRIPTION_RESOURCE_TYPE ON APPM_SUBSCRIPTION(RESOURCE_TYPE_ID ASC);
CREATE INDEX FK_APPLICATION_SUBSCRIPTION_APPLICATION ON APPM_SUBSCRIPTION(APPLICATION_ID ASC);
CREATE INDEX FK_APPLICATION_SUBSCRIPTION_APPLICATION_RELEASE ON APPM_SUBSCRIPTION(APPLICATION_RELEASE_ID ASC);
-- -----------------------------------------------------
-- Table APPM_COMMENT
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_COMMENT (
ID INT NOT NULL AUTO_INCREMENT,
APPLICATION_RELEASE_ID INT NOT NULL,
COMMENT_SUBJECT VARCHAR(255) NULL,
COMMENT_BODY TEXT NULL,
RATING INT NULL,
PARENT_ID INT NULL,
CREATED_AT DATETIME NOT NULL,
CREATED_BY VARCHAR(45) NULL,
MODIFIED_AT DATETIME NULL,
PUBLISHED TINYINT NULL,
PRIMARY KEY (ID, APPLICATION_RELEASE_ID),
CONSTRAINT FK_APPLICATION_COMMENTS_APPLICATION_RELEASE
FOREIGN KEY (APPLICATION_RELEASE_ID)
REFERENCES APPM_APPLICATION_RELEASE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE INDEX FK_APPLICATION_COMMENTS_APPLICATION_RELEASE ON APPM_COMMENT(APPLICATION_RELEASE_ID ASC);
-- -----------------------------------------------------
-- Table APPM_PLATFORM_TAG
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_PLATFORM_TAG (
name VARCHAR(100) NOT NULL,
PLATFORM_ID INT NOT NULL,
PRIMARY KEY (PLATFORM_ID, name),
CONSTRAINT fk_APPM_SUPPORTED_PLATFORM_TAGS_APPM_SUPPORTED_PLATFORM1
FOREIGN KEY (PLATFORM_ID)
REFERENCES APPM_PLATFORM (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE INDEX FK_PLATFORM_TAGS_PLATFORM ON APPM_PLATFORM_TAG(PLATFORM_ID ASC);
-- -----------------------------------------------------
-- Table APPM_APPLICATION_TAG
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_APPLICATION_TAG (
name VARCHAR(45) NOT NULL,
APPLICATION_ID INT NOT NULL,
PRIMARY KEY (APPLICATION_ID, name),
CONSTRAINT fk_APPM_APPLICATION_TAG_APPM_APPLICATION1
FOREIGN KEY (APPLICATION_ID)
REFERENCES APPM_APPLICATION (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE INDEX FK_APPLICATION_TAG_APPLICATION ON APPM_APPLICATION_TAG(APPLICATION_ID ASC);
-- -----------------------------------------------------
-- Table APPM_VISIBILITY
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_VISIBILITY (
ID INT NOT NULL AUTO_INCREMENT,
VALUE VARCHAR(255) NOT NULL,
RESOURCE_TYPE_ID INT NOT NULL,
APPLICATION_RELEASE_ID INT NULL,
APPLICATION_ID INT NULL,
PRIMARY KEY (ID, RESOURCE_TYPE_ID),
CONSTRAINT fk_APPM_VISIBILITY_APPM_RESOURCE_TYPE1
FOREIGN KEY (RESOURCE_TYPE_ID)
REFERENCES APPM_RESOURCE_TYPE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT fk_APPM_VISIBILITY_APPM_APPLICATION_RELEASE1
FOREIGN KEY (APPLICATION_RELEASE_ID)
REFERENCES APPM_APPLICATION_RELEASE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT fk_APPM_VISIBILITY_APPM_APPLICATION1
FOREIGN KEY (APPLICATION_ID)
REFERENCES APPM_APPLICATION (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE INDEX FK_APPM_VISIBILITY_RESOURCE_TYPE ON APPM_VISIBILITY(RESOURCE_TYPE_ID ASC);
CREATE INDEX FK_VISIBILITY_APPLICATION_RELEASE ON APPM_VISIBILITY(APPLICATION_RELEASE_ID ASC);
CREATE INDEX FK_VISIBILITY_APPLICATION ON APPM_VISIBILITY(APPLICATION_ID ASC);
-- -----------------------------------------------------
-- Table APPM_SUBSCRIPTION_PROPERTIES
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS APPM_SUBSCRIPTION_PROPERTIES (
PROP_KEY TEXT NOT NULL,
PROP_VALUE TEXT NULL,
APPM_SUBSCRIPTION_ID INT NOT NULL,
PRIMARY KEY (PROP_KEY, APPM_SUBSCRIPTION_ID),
CONSTRAINT fk_APPM_SUBSCRIPTION_PROPERTIES_APPM_SUBSCRIPTION1
FOREIGN KEY (APPM_SUBSCRIPTION_ID)
REFERENCES APPM_SUBSCRIPTION (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
CREATE INDEX FK_SUBSCRIPTION_PROPERTIES_SUBSCRIPTION ON APPM_SUBSCRIPTION_PROPERTIES(APPM_SUBSCRIPTION_ID ASC);

@ -114,7 +114,7 @@ CREATE TABLE IF NOT EXISTS `APPM_LIFECYCLE_STATE` (
`IDENTIFIER` VARCHAR(100) NOT NULL, `IDENTIFIER` VARCHAR(100) NOT NULL,
`DESCRIPTION` TEXT NULL, `DESCRIPTION` TEXT NULL,
PRIMARY KEY (`ID`), PRIMARY KEY (`ID`),
UNIQUE INDEX `IDENTIFIER_UNIQUE` (`IDENTIFIER` ASC)) UNIQUE INDEX `IDENTIFIER_UNIQUE1` (`IDENTIFIER` ASC))
ENGINE = InnoDB; ENGINE = InnoDB;

Loading…
Cancel
Save