diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql index f16927301b..d2255a78ff 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql @@ -12,9 +12,55 @@ CREATE TABLE IF NOT EXISTS AP_APP( CURRENCY VARCHAR(45) NULL DEFAULT '$', RATING DOUBLE NULL DEFAULT NULL, DEVICE_TYPE_ID INTEGER NOT NULL, + ADAM_ID VARCHAR(45) NULL DEFAULT '0' UNIQUE , PRIMARY KEY (ID) ); +-- ----------------------------------------------------- +-- Table AP_VPP_LICENSE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AP_VPP_LICENSE +( + LICENSE_ID INTEGER NOT NULL AUTO_INCREMENT, + ADAM_ID VARCHAR(45) NOT NULL UNIQUE , + AVAILABILITY VARCHAR(350) NOT NULL, + PRIMARY KEY (LICENSE_ID), + CONSTRAINT fk_AP_VPP_LICENSE_AP_APP1 + FOREIGN KEY (ADAM_ID) + REFERENCES AP_APP (ADAM_ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); +CREATE INDEX fk_AP_VPP_LICENSE_AP_APP1_idx ON AP_VPP_LICENSE (ADAM_ID ASC); + +-- ----------------------------------------------------- +-- Table AP_VPP_DEVICE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AP_VPP_DEVICE +( + ID INTEGER NOT NULL AUTO_INCREMENT, + SERIAL_NUMBER INTEGER NOT NULL, + USER_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +); + +-- ----------------------------------------------------- +-- Table AP_VPP_DEVICE_LICENSE_MAPPING +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AP_VPP_DEVICE_LICENSE_MAPPING +( + LICENSE_ID INTEGER NOT NULL, + DEVICE_ID INTEGER NOT NULL, + PRIMARY KEY (LICENSE_ID, DEVICE_ID), + CONSTRAINT fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_DEVICE + FOREIGN KEY (DEVICE_ID) + REFERENCES AP_VPP_DEVICE (ID), + CONSTRAINT fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_LICENSE + FOREIGN KEY (LICENSE_ID) + REFERENCES AP_VPP_LICENSE (LICENSE_ID) +); +CREATE INDEX fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_DEVICE_idx ON AP_VPP_DEVICE (ID ASC); +CREATE INDEX fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_LICENSE_idx ON AP_VPP_LICENSE (LICENSE_ID ASC); + + -- ----------------------------------------------------- -- Table AP_APP_RELEASE -- ----------------------------------------------------- diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql index 78e05c1371..b6899600b2 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql @@ -12,9 +12,57 @@ CREATE TABLE AP_APP( CURRENCY VARCHAR(45) NULL DEFAULT '$', RATING FLOAT NULL DEFAULT NULL, DEVICE_TYPE_ID INTEGER NOT NULL, + ADAM_ID VARCHAR(45) NULL DEFAULT '0' , + CONSTRAINT ADAM_ID_CONSTRAINT UNIQUE (ADAM_ID), PRIMARY KEY (ID) ); +-- ----------------------------------------------------- +-- Table AP_VPP_LICENSE +-- ----------------------------------------------------- +CREATE TABLE AP_VPP_LICENSE +( + LICENSE_ID INTEGER NOT NULL IDENTITY, + ADAM_ID VARCHAR(45) NOT NULL , + AVAILABILITY VARCHAR(350) NOT NULL, + PRIMARY KEY (LICENSE_ID), + CONSTRAINT ADAMID_CONSTRAINT UNIQUE (ADAM_ID), + CONSTRAINT fk_AP_VPP_LICENSE_AP_APP1 + FOREIGN KEY (ADAM_ID) + REFERENCES AP_APP (ADAM_ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); +CREATE INDEX fk_AP_VPP_LICENSE_AP_APP1_idx ON AP_VPP_LICENSE (ADAM_ID ASC); + +-- ----------------------------------------------------- +-- Table AP_VPP_DEVICE +-- ----------------------------------------------------- +CREATE TABLE AP_VPP_DEVICE +( + ID INTEGER NOT NULL IDENTITY,, + SERIAL_NUMBER INTEGER NOT NULL, + USER_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +); + +-- ----------------------------------------------------- +-- Table AP_VPP_DEVICE_LICENSE_MAPPING +-- ----------------------------------------------------- +CREATE TABLE AP_VPP_DEVICE_LICENSE_MAPPING +( + LICENSE_ID INTEGER NOT NULL, + DEVICE_ID INTEGER NOT NULL, + PRIMARY KEY (LICENSE_ID, DEVICE_ID), + CONSTRAINT fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_DEVICE + FOREIGN KEY (DEVICE_ID) + REFERENCES AP_VPP_DEVICE (ID), + CONSTRAINT fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_LICENSE + FOREIGN KEY (LICENSE_ID) + REFERENCES AP_VPP_LICENSE (LICENSE_ID) +); +CREATE INDEX fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_DEVICE_idx ON AP_VPP_DEVICE (ID ASC); +CREATE INDEX fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_LICENSE_idx ON AP_VPP_LICENSE (LICENSE_ID ASC); + + -- ----------------------------------------------------- -- Table AP_APP_RELEASE -- ----------------------------------------------------- diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql index 1daa796858..cb1dd50e59 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mysql.sql @@ -12,9 +12,51 @@ CREATE TABLE IF NOT EXISTS AP_APP( CURRENCY VARCHAR(45) NULL DEFAULT '$', RATING DOUBLE NULL DEFAULT NULL, DEVICE_TYPE_ID INTEGER NOT NULL, + ADAM_ID VARCHAR(45) NULL DEFAULT '0' UNIQUE , PRIMARY KEY (ID) ); +-- ----------------------------------------------------- +-- Table AP_VPP_LICENSE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AP_VPP_LICENSE( + LICENSE_ID INTEGER NOT NULL AUTO_INCREMENT, + ADAM_ID VARCHAR(45) NOT NULL UNIQUE , + AVAILABILITY VARCHAR(350) NOT NULL, + PRIMARY KEY (LICENSE_ID), + CONSTRAINT fk_AP_VPP_LICENSE_AP_APP1 + FOREIGN KEY (ADAM_ID) + REFERENCES AP_APP (ADAM_ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); +CREATE INDEX fk_AP_VPP_LICENSE_AP_APP1_idx ON AP_VPP_LICENSE (ADAM_ID ASC); + +-- ----------------------------------------------------- +-- Table AP_VPP_DEVICE +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AP_VPP_DEVICE( + ID INTEGER NOT NULL AUTO_INCREMENT, + SERIAL_NUMBER INTEGER NOT NULL, + USER_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +); + +-- ----------------------------------------------------- +-- Table AP_VPP_DEVICE_LICENSE_MAPPING +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AP_VPP_DEVICE_LICENSE_MAPPING( + LICENSE_ID INTEGER NOT NULL, + DEVICE_ID INTEGER NOT NULL, + PRIMARY KEY (LICENSE_ID, DEVICE_ID), + CONSTRAINT fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_DEVICE + FOREIGN KEY (DEVICE_ID) + REFERENCES AP_VPP_DEVICE (ID), + CONSTRAINT fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_LICENSE + FOREIGN KEY (LICENSE_ID) + REFERENCES AP_VPP_LICENSE (LICENSE_ID) +); +CREATE INDEX fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_DEVICE_idx ON AP_VPP_DEVICE (ID ASC); +CREATE INDEX fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_LICENSE_idx ON AP_VPP_LICENSE (LICENSE_ID ASC); + -- ----------------------------------------------------- -- Table AP_APP_RELEASE -- ----------------------------------------------------- diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql index c4f2c99f06..c952127b97 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/oracle.sql @@ -228,6 +228,7 @@ INSERT INTO APPM_LC_STATE_TRANSITION(INITIAL_STATE, NEXT_STATE, PERMISSION, DESC CREATE TABLE APPM_APPLICATION ( ID INT UNIQUE, UUID VARCHAR(100) NOT NULL, + ADAM_ID VARCHAR(100) DEFAULT '0', IDENTIFIER VARCHAR(255) NULL, NAME VARCHAR(100) NOT NULL, SHORT_DESCRIPTION VARCHAR(255) NULL, @@ -255,6 +256,9 @@ CREATE TABLE APPM_APPLICATION ( CREATE INDEX UUID_UNIQUE ON APPM_APPLICATION(UUID ASC) / +CREATE INDEX ADAM_ID_UNIQUE ON APPM_APPLICATION(ADAM_ID ASC) +/ + CREATE INDEX FK_APP_APP_CATEGORY ON APPM_APPLICATION(APPLICATION_CATEGORY_ID ASC) / @@ -277,6 +281,82 @@ CREATE OR REPLACE TRIGGER APPM_APPLICATION_TRIG END; / +-- ----------------------------------------------------- +-- Table AP_VPP_LICENSE +-- ----------------------------------------------------- +CREATE TABLE AP_VPP_LICENSE( + LICENSE_ID NUMBER(10) NOT NULL, + ADAM_ID VARCHAR2(45) NOT NULL UNIQUE , + AVAILABILITY VARCHAR2(350) NOT NULL, + PRIMARY KEY (LICENSE_ID), + CONSTRAINT FK_AP_VPP_LICENSE_AP_APP + FOREIGN KEY (ADAM_ID) + REFERENCES APPM_APPLICATION (ADAM_ID) +); +/ + +CREATE SEQUENCE AP_VPP_LICENSE_SEQ START WITH 1 INCREMENT BY 1; +/ + +CREATE OR REPLACE TRIGGER AP_VPP_LICENSE_TRIG + BEFORE INSERT + ON AP_VPP_LICENSE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT AP_VPP_LICENSE_SEQ.nextval INTO :NEW.LICENSE_ID FROM dual; + END; +/ + +CREATE INDEX fk_AP_VPP_LICENSE_AP_APP1_idx ON AP_VPP_LICENSE (ADAM_ID ASC); +/ + +-- ----------------------------------------------------- +-- Table AP_VPP_DEVICE +-- ----------------------------------------------------- +CREATE TABLE AP_VPP_DEVICE( + ID NUMBER(10) NOT NULL, + SERIAL_NUMBER NUMBER(10) NOT NULL, + USER_ID NUMBER(10) NOT NULL, + PRIMARY KEY (ID) +); +/ + +CREATE SEQUENCE AP_VPP_DEVICE_SEQ START WITH 1 INCREMENT BY 1; +/ + +CREATE OR REPLACE TRIGGER AP_VPP_DEVICE_TRIG + BEFORE INSERT + ON AP_VPP_DEVICE + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT AP_VPP_DEVICE_SEQ.nextval INTO :NEW.ID FROM dual; + END; +/ + +-- ----------------------------------------------------- +-- Table AP_VPP_DEVICE_LICENSE_MAPPING +-- ----------------------------------------------------- +CREATE TABLE AP_VPP_DEVICE_LICENSE_MAPPING( + LICENSE_ID NUMBER(10) NOT NULL, + DEVICE_ID NUMBER(10) NOT NULL, + PRIMARY KEY (LICENSE_ID, DEVICE_ID), + CONSTRAINT fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_DEVICE + FOREIGN KEY (DEVICE_ID) + REFERENCES AP_VPP_DEVICE (ID), + CONSTRAINT fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_LICENSE + FOREIGN KEY (LICENSE_ID) + REFERENCES AP_VPP_LICENSE (LICENSE_ID) +); +/ + +CREATE INDEX fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_DEVICE_idx ON AP_VPP_DEVICE (ID ASC); +/ + +CREATE INDEX fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_LICENSE_idx ON AP_VPP_LICENSE (LICENSE_ID ASC); +/ + -- ----------------------------------------------------- -- Table APPM_APPLICATION_PROPERTY -- ----------------------------------------------------- diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql index 5c20aa4a75..e30249eb8f 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/postgresql.sql @@ -14,9 +14,58 @@ CREATE TABLE IF NOT EXISTS AP_APP( CURRENCY VARCHAR(45) NULL DEFAULT '$', RATING DOUBLE PRECISION NULL DEFAULT NULL, DEVICE_TYPE_ID INTEGER NOT NULL, + ADAM_ID VARCHAR(45) NULL DEFAULT '0' UNIQUE, PRIMARY KEY (ID) ); +-- ----------------------------------------------------- +-- Table AP_VPP_LICENSE +-- ----------------------------------------------------- +CREATE SEQUENCE AP_VPP_LICENSE_seq; + +CREATE TABLE IF NOT EXISTS AP_VPP_LICENSE( + LICENSE_ID INTEGER NOT NULL DEFAULT NEXTVAL ('AP_VPP_LICENSE_seq'), + ADAM_ID VARCHAR(45) NOT NULL UNIQUE , + AVAILABILITY VARCHAR(350) NOT NULL, + PRIMARY KEY (LICENSE_ID), + CONSTRAINT fk_AP_VPP_LICENSE_AP_APP1 + FOREIGN KEY (ADAM_ID) + REFERENCES AP_APP (ADAM_ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); +CREATE INDEX fk_AP_VPP_LICENSE_AP_APP1_idx ON AP_VPP_LICENSE (ADAM_ID ASC); + +-- ----------------------------------------------------- +-- Table AP_VPP_DEVICE +-- ----------------------------------------------------- +CREATE SEQUENCE AP_VPP_DEVICE_seq; + +CREATE TABLE IF NOT EXISTS AP_VPP_DEVICE +( + ID INTEGER NOT NULL DEFAULT NEXTVAL ('AP_VPP_DEVICE_seq'), + SERIAL_NUMBER INTEGER NOT NULL, + USER_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +); + +-- ----------------------------------------------------- +-- Table AP_VPP_DEVICE_LICENSE_MAPPING +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS AP_VPP_DEVICE_LICENSE_MAPPING +( + LICENSE_ID INTEGER NOT NULL, + DEVICE_ID INTEGER NOT NULL, + PRIMARY KEY (LICENSE_ID, DEVICE_ID), + CONSTRAINT fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_DEVICE + FOREIGN KEY (DEVICE_ID) + REFERENCES AP_VPP_DEVICE (ID), + CONSTRAINT fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_LICENSE + FOREIGN KEY (LICENSE_ID) + REFERENCES AP_VPP_LICENSE (LICENSE_ID) +); +CREATE INDEX fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_DEVICE_idx ON AP_VPP_DEVICE (ID ASC); +CREATE INDEX fk_AP_VPP_DEVICE_LICENSE_MAPPING_AP_VPP_LICENSE_idx ON AP_VPP_LICENSE (LICENSE_ID ASC); + + -- ----------------------------------------------------- -- Table AP_APP_RELEASE -- -----------------------------------------------------