From 8c1f87a06e06557124ef13cfecbdb0a8bfaaadc4 Mon Sep 17 00:00:00 2001 From: DMHP Date: Tue, 26 Jun 2018 16:09:27 +0530 Subject: [PATCH] Fix error occur during the migration from WSO2IS-5.3.0 to WSO2IS-5.5.0 --- .../5.5.0/dbscripts/step1/identity/db2.sql | 13 ++++++++++ .../5.5.0/dbscripts/step1/identity/h2.sql | 2 ++ .../5.5.0/dbscripts/step1/identity/mssql.sql | 2 ++ .../5.5.0/dbscripts/step1/identity/mysql.sql | 2 ++ .../dbscripts/step1/identity/mysql5.7.sql | 2 ++ .../5.5.0/dbscripts/step1/identity/oracle.sql | 26 +++++++++++++++++++ .../dbscripts/step1/identity/postgresql.sql | 2 ++ 7 files changed, 49 insertions(+) diff --git a/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/db2.sql b/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/db2.sql index 5622a66167a..b02cbfb678c 100644 --- a/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/db2.sql +++ b/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/db2.sql @@ -1,3 +1,16 @@ +BEGIN + DECLARE CONTINUE HANDLER FOR SQLSTATE '42704' + BEGIN END; + EXECUTE IMMEDIATE 'DROP INDEX IDX_AT'; +END +/ + +BEGIN + DECLARE CONTINUE HANDLER FOR SQLSTATE '42704' + BEGIN END; + EXECUTE IMMEDIATE 'DROP INDEX IDX_AUTHORIZATION_CODE'; +END +/ ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN ALTER COLUMN REFRESH_TOKEN SET DATA TYPE VARCHAR(2048) / ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN ALTER COLUMN ACCESS_TOKEN SET DATA TYPE VARCHAR(2048) diff --git a/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/h2.sql b/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/h2.sql index 5f4f2f7686f..5fd3342c449 100644 --- a/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/h2.sql +++ b/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/h2.sql @@ -1,3 +1,5 @@ +DROP INDEX IF EXISTS IDX_AT ON IDN_OAUTH2_ACCESS_TOKEN; +DROP INDEX IF EXISTS IDX_AUTHORIZATION_CODE ON IDN_OAUTH2_AUTHORIZATION_CODE; ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN modify REFRESH_TOKEN VARCHAR(2048); ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN modify ACCESS_TOKEN VARCHAR(2048); ALTER TABLE IDN_OAUTH2_AUTHORIZATION_CODE modify AUTHORIZATION_CODE VARCHAR(2048); diff --git a/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/mssql.sql b/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/mssql.sql index a19d9bcb59d..abd35f9155f 100644 --- a/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/mssql.sql +++ b/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/mssql.sql @@ -1,3 +1,5 @@ +IF EXISTS (SELECT * FROM sys.indexes WHERE name='IDX_AT') begin DROP INDEX IDN_OAUTH2_ACCESS_TOKEN.IDX_AT; end; +IF EXISTS (SELECT * FROM sys.indexes WHERE name='IDX_AUTHORIZATION_CODE') begin DROP INDEX IDN_OAUTH2_AUTHORIZATION_CODE.IDX_AUTHORIZATION_CODE; end; ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN ALTER COLUMN ACCESS_TOKEN VARCHAR(2048); ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN ALTER COLUMN REFRESH_TOKEN VARCHAR(2048); ALTER TABLE IDN_OAUTH2_AUTHORIZATION_CODE ALTER COLUMN AUTHORIZATION_CODE VARCHAR(2048); diff --git a/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/mysql.sql b/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/mysql.sql index 61db410681a..6e8c2856e10 100644 --- a/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/mysql.sql +++ b/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/mysql.sql @@ -1,3 +1,5 @@ +DROP INDEX IDX_AT ON IDN_OAUTH2_ACCESS_TOKEN; +DROP INDEX IDX_AUTHORIZATION_CODE ON IDN_OAUTH2_AUTHORIZATION_CODE; ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN modify REFRESH_TOKEN VARCHAR(2048); ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN modify ACCESS_TOKEN VARCHAR(2048); diff --git a/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/mysql5.7.sql b/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/mysql5.7.sql index d8946d3f4f6..c5cc3323ea6 100644 --- a/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/mysql5.7.sql +++ b/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/mysql5.7.sql @@ -1,3 +1,5 @@ +DROP INDEX IDX_AT ON IDN_OAUTH2_ACCESS_TOKEN; +DROP INDEX IDX_AUTHORIZATION_CODE ON IDN_OAUTH2_AUTHORIZATION_CODE; ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN modify REFRESH_TOKEN VARCHAR(2048); ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN modify ACCESS_TOKEN VARCHAR(2048); ALTER TABLE IDN_OAUTH2_AUTHORIZATION_CODE modify AUTHORIZATION_CODE VARCHAR(2048); diff --git a/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/oracle.sql b/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/oracle.sql index eb97ac23c03..58256e432c0 100644 --- a/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/oracle.sql +++ b/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/oracle.sql @@ -1,3 +1,29 @@ +DECLARE + COUNT_INDEXES INTEGER; + BEGIN + SELECT COUNT(*) INTO COUNT_INDEXES + FROM USER_INDEXES + WHERE INDEX_NAME = 'IDX_AT'; + + IF COUNT_INDEXES > 0 THEN + EXECUTE IMMEDIATE 'DROP INDEX IDX_AT'; + END IF; + END; + + DECLARE + COUNT_INDEXES INTEGER; + BEGIN + SELECT COUNT(*) INTO COUNT_INDEXES + FROM USER_INDEXES + WHERE INDEX_NAME = 'IDX_AUTHORIZATION_CODE'; + + IF COUNT_INDEXES > 0 THEN + EXECUTE IMMEDIATE 'DROP INDEX IDX_AUTHORIZATION_CODE'; + END IF; + END; + +END; +/ ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN modify REFRESH_TOKEN VARCHAR(2048) / ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN modify ACCESS_TOKEN VARCHAR(2048) diff --git a/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/postgresql.sql b/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/postgresql.sql index 402873a2c12..3d1c750725a 100644 --- a/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/postgresql.sql +++ b/modules/migration/migration-resources/5.5.0/dbscripts/step1/identity/postgresql.sql @@ -1,3 +1,5 @@ +DROP INDEX IF EXISTS IDX_AT; +DROP INDEX IF EXISTS IDX_AUTHORIZATION_CODE; ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN ALTER COLUMN REFRESH_TOKEN TYPE VARCHAR(2048); ALTER TABLE IDN_OAUTH2_ACCESS_TOKEN ALTER COLUMN ACCESS_TOKEN TYPE VARCHAR(2048); ALTER TABLE IDN_OAUTH2_AUTHORIZATION_CODE ALTER COLUMN AUTHORIZATION_CODE TYPE VARCHAR(2048);