diff --git a/migration-scripts/appm/appm382to530.sql b/migration-scripts/appm/appm-migration.sql similarity index 72% rename from migration-scripts/appm/appm382to530.sql rename to migration-scripts/appm/appm-migration.sql index 2990ce1..25d4ac0 100644 --- a/migration-scripts/appm/appm382to530.sql +++ b/migration-scripts/appm/appm-migration.sql @@ -153,3 +153,51 @@ CREATE TABLE AP_APP_FAVOURITES( FOREIGN KEY (AP_APP_ID) REFERENCES AP_APP (ID) ); + +--uem 5.3.2.0 to uem 5.3.3.0 + +CREATE TABLE AP_VPP_USER ( + ID INT NOT NULL IDENTITY(1,1), + CLIENT_USER_ID VARCHAR(255) NULL, + DM_USERNAME VARCHAR(255) NOT NULL, + TENANT_ID INT NOT NULL, + EMAIL VARCHAR(255) NULL, + INVITE_CODE VARCHAR(255) NULL, + STATUS VARCHAR(255) NULL, + CREATED_TIME BIGINT NULL, + LAST_UPDATED_TIME BIGINT NULL, + MANAGED_ID VARCHAR(255) NULL, + TEMP_PASSWORD VARCHAR(255) NULL, + PRIMARY KEY (ID) +); + +CREATE TABLE AP_ASSETS ( + ID INT NOT NULL IDENTITY(1,1), + APP_ID INT NULL, + TENANT_ID INT NOT NULL, + CREATED_TIME BIGINT NULL, + LAST_UPDATED_TIME BIGINT NULL, + ADAM_ID VARCHAR(255) NULL, + ASSIGNED_COUNT VARCHAR(255) NULL, + DEVICE_ASSIGNABLE VARCHAR(255) NULL, + PRICING_PARAMS VARCHAR(255) NULL, + PRODUCT_TYPE VARCHAR(255) NULL, + RETIRED_COUNT VARCHAR(255) NULL, + REVOCABLE VARCHAR(255) NULL, + SUPPORTED_PLATFORMS VARCHAR(255) NULL, + PRIMARY KEY (ID) +); + +CREATE TABLE AP_VPP_ASSOCIATION ( + ID INT NOT NULL IDENTITY(1,1), + ASSET_ID INT, + USER_ID INT, + TENANT_ID INT NOT NULL, + ASSOCIATION_TYPE VARCHAR(255) NOT NULL, + CREATED_TIME BIGINT NULL, + LAST_UPDATED_TIME BIGINT NULL, + PRICING_PARAMS VARCHAR(255) NULL, + PRIMARY KEY (ID), + CONSTRAINT AP_VPP_ASSETS_fk FOREIGN KEY (ASSET_ID) REFERENCES AP_ASSETS (ID) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT AP_VPP_VPP_USER_fk FOREIGN KEY (USER_ID) REFERENCES AP_VPP_USER (ID) ON DELETE CASCADE ON UPDATE CASCADE +); diff --git a/migration-scripts/cdm/cdm382to530.sql b/migration-scripts/cdm/cdm-migration.sql similarity index 84% rename from migration-scripts/cdm/cdm382to530.sql rename to migration-scripts/cdm/cdm-migration.sql index 060cb1a..7e5c45d 100644 --- a/migration-scripts/cdm/cdm382to530.sql +++ b/migration-scripts/cdm/cdm-migration.sql @@ -1,4 +1,4 @@ -use DM_DB530; +use bst_mdmdm_db; -- iot 3.8.2 to iot 4.0.0 migration ALTER TABLE DM_OPERATION @@ -77,11 +77,11 @@ ALTER TABLE DM_OPERATION ALTER COLUMN RECEIVED_TIMESTAMP BIGINT NULL; -- Drop tables not in 5.3.0 -DROP TABLE DM_CONFIG_OPERATION; -DROP TABLE DM_COMMAND_OPERATION; -DROP TABLE DM_POLICY_OPERATION; -DROP TABLE DM_PROFILE_OPERATION; -DROP TABLE DM_DEVICE_APPLICATION_MAPPING; +--DROP TABLE DM_CONFIG_OPERATION; +--DROP TABLE DM_COMMAND_OPERATION; +--DROP TABLE DM_POLICY_OPERATION; +--DROP TABLE DM_PROFILE_OPERATION; +--DROP TABLE DM_DEVICE_APPLICATION_MAPPING; -- iot 4.0.0 to iot 4.1.0 migration ALTER TABLE DM_POLICY @@ -361,3 +361,62 @@ CREATE TABLE DYNAMIC_TASK_PROPERTIES ( CONSTRAINT FK_DYNAMIC_TASK_TASK_PROPERTIES FOREIGN KEY (DYNAMIC_TASK_ID) REFERENCES DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE ); + +-- uem 5.3.2.0 to uem 5.3.3.0 + +ALTER TABLE DM_OPERATION +ADD TENANT_ID INTEGER NOT NULL; + +IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_OP_CREATED' AND OBJECT_ID = OBJECT_ID('DM_OPERATION')) +CREATE INDEX IDX_OP_CREATED ON DM_OPERATION(CREATED_TIMESTAMP); +IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_OP_CODE' AND OBJECT_ID = OBJECT_ID('DM_OPERATION')) +CREATE INDEX IDX_OP_CODE ON DM_OPERATION(OPERATION_CODE); +IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_OP_INITIATED_BY' AND OBJECT_ID = OBJECT_ID('DM_OPERATION')) +CREATE INDEX IDX_OP_INITIATED_BY ON DM_OPERATION(INITIATED_BY); + +IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_ENROLMENT_OP_MAPPING_CREATED_TS' AND OBJECT_ID = OBJECT_ID('DM_ENROLMENT_OP_MAPPING')) +CREATE INDEX IDX_ENROLMENT_OP_MAPPING_CREATED_TS ON DM_ENROLMENT_OP_MAPPING(CREATED_TIMESTAMP); + +ALTER TABLE DM_METADATA +ALTER COLUMN METADATA_VALUE TEXT NOT NULL; + +ALTER TABLE DM_OTP_DATA +ALTER COLUMN META_INFO VARCHAR(8000) NULL; + +IF NOT EXISTS (SELECT * FROM SYS.VIEWS WHERE NAME = 'FEATURE_NON_COMPLIANCE_INFO') +exec('CREATE VIEW FEATURE_NON_COMPLIANCE_INFO AS +SELECT TOP 100 PERCENT +DM_DEVICE.ID AS DEVICE_ID, +DM_DEVICE.DEVICE_IDENTIFICATION, +DM_DEVICE_DETAIL.DEVICE_MODEL, +DM_DEVICE_DETAIL.VENDOR, +DM_DEVICE_DETAIL.OS_VERSION, +DM_ENROLMENT.OWNERSHIP, +DM_ENROLMENT.OWNER, +DM_ENROLMENT.STATUS AS CONNECTIVITY_STATUS, +DM_POLICY_COMPLIANCE_STATUS.POLICY_ID, +DM_DEVICE_TYPE.NAME +AS PLATFORM, +DM_POLICY_COMPLIANCE_FEATURES.FEATURE_CODE, +DM_POLICY_COMPLIANCE_FEATURES.STATUS AS IS_COMPLAINT, +DM_DEVICE.TENANT_ID +FROM +DM_POLICY_COMPLIANCE_FEATURES, DM_POLICY_COMPLIANCE_STATUS, DM_ENROLMENT, DM_DEVICE, DM_DEVICE_TYPE, DM_DEVICE_DETAIL +WHERE +DM_POLICY_COMPLIANCE_FEATURES.COMPLIANCE_STATUS_ID = DM_POLICY_COMPLIANCE_STATUS.ID AND +DM_POLICY_COMPLIANCE_STATUS.ENROLMENT_ID = +DM_ENROLMENT.ID AND +DM_POLICY_COMPLIANCE_STATUS.DEVICE_ID = DM_DEVICE.ID AND +DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND +DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID +ORDER BY TENANT_ID, DEVICE_ID'); + +ALTER TABLE DM_DEVICE_SUB_TYPE +ALTER COLUMN DEVICE_TYPE VARCHAR(45) NOT NULL; + +ALTER TABLE DM_DEVICE_SUB_TYPE +ALTER COLUMN SUB_TYPE_NAME VARCHAR(100) NOT NULL; + +ALTER TABLE SUB_OPERATION_TEMPLATE +ALTER COLUMN DEVICE_TYPE VARCHAR(45) NOT NULL; + diff --git a/migration-scripts/run-migration.sh b/migration-scripts/run-migration.sh index ce4817c..b5d7918 100644 --- a/migration-scripts/run-migration.sh +++ b/migration-scripts/run-migration.sh @@ -15,10 +15,10 @@ DB_PASS=Cpbac7690# CURRENT_DIRECTORY=$(pwd) APIM_IDP_SCRIPT="${CURRENT_DIRECTORY}/apim/idp-migration.sql" -#REG_SCRIPT="${CURRENT_DIRECTORY}/REG/REG-migration.sql" +REG_SCRIPT="${CURRENT_DIRECTORY}/reg/reg-migration.sql" #UM_SCRIPT="${CURRENT_DIRECTORY}/UM/um-migration.sql" -CDM_SCRIPT="${CURRENT_DIRECTORY}/cdm/cdm382to530.sql" -APPM_SCRIPT="${CURRENT_DIRECTORY}/appm/appm382to530.sql" +CDM_SCRIPT="${CURRENT_DIRECTORY}/cdm/cdm-migration.sql" +APPM_SCRIPT="${CURRENT_DIRECTORY}/appm/appm-migration.sql" echo "$(timestamp) : Migrating AM_DB IDP tables " echo ""