Change DB scripts

vpp^2
amanda 5 years ago
parent e7fc9c3c74
commit f0c63e4cbe

@ -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
-- -----------------------------------------------------

@ -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
-- -----------------------------------------------------

@ -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
-- -----------------------------------------------------

@ -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
-- -----------------------------------------------------

@ -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
-- -----------------------------------------------------

Loading…
Cancel
Save