wso2 / product-is

Welcome to the WSO2 Identity Server source code! For info on working with the WSO2 Identity Server repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
727 stars 712 forks source link

v7.0.0 data migration fails in step 1 with Oracle DB when migrating from older versions #20559

Open sanjulamadurapperuma opened 2 weeks ago

sanjulamadurapperuma commented 2 weeks ago

Describe the issue:

When performing a data migration from older versions (i.e. for example, v5.7.0), the following error occurs during step 1 of v7.0.0 when using Oracle database.

ERROR {org.wso2.carbon.is.migration.service.SchemaMigrator} - Error occurred while executing SQL script for migrating database java.lang.Exception: Error occurred while executing :  ALTER TABLE UM_HYBRID_ROLE DROP UNIQUE (UM_ROLE_NAME, UM_TENANT_ID)
...
Caused by: java.sql.SQLException: ORA-02442: Cannot drop nonexistent unique key

https://docs.oracle.com/error-help/db/ora-02442/
...
Caused by: Error : 2442, Position : 41, SQL =  ALTER TABLE UM_HYBRID_ROLE DROP UNIQUE (UM_ROLE_NAME, UM_TENANT_ID) , Original SQL =  ALTER TABLE UM_HYBRID_ROLE DROP UNIQUE (UM_ROLE_NAME, UM_TENANT_ID) , Error Message = ORA-02442: Cannot drop nonexistent unique key

When investigating further, it was observed that the unique key mentioned in the error above (UM_ROLE_NAME, UM_TENANT_ID), does not exist in the database, nor is it added via the migration client before coming to the migration steps in v7.0.0 as per the migration-config.yaml file. Therefore, it is trying to remove a unique key that does not exist in the database. The workaround for this issue is to remove the relevant ALTER query manually from the script.

This needs to be fixed in the script to handle use cases where migrations occur from legacy/older versions and not try to drop a non-existing constraint.

Optional Fields

Related issues:

Suggested labels: