LTS Oracle DB Migration not working from 7.9.4 LTS to 8.9.0 LTS

We have upgraded our Sonarqube LTS Enterprise Version 7.9.4 to 8.9.0 on out Test Stage one week before and this was working without any Problems.

Today we tried to do the same Steps und our Productive Stage and the DB Migration Process failed
with the following Steps:

2021.06.11 13:37:46 INFO  web[][DbMigrations] Executing DB migrations...
2021.06.11 13:37:46 INFO  web[][DbMigrations] #3307 'Remove column 'resource_id' in 'group_roles''...
2021.06.11 13:37:46 ERROR web[][DbMigrations] #3307 'Remove column 'resource_id' in 'group_roles'': failure | time=45ms
2021.06.11 13:37:46 ERROR web[][DbMigrations] Executed DB migrations: failure | time=47ms
2021.06.11 13:37:46 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration failed | time=276ms
2021.06.11 13:37:46 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration ended with an exception
org.sonar.server.platform.db.migration.step.MigrationStepExecutionException: Execution of migration step #3307 'Remove column 'resource_id' in 'group_roles'' failed
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(
        at org.sonar.server.platform.db.migration.engine.MigrationEngineImpl.execute(
        at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doUpgradeDb(
        at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doDatabaseMigration(
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(
        at java.base/java.util.concurrent.ThreadPoolExecutor$
        at java.base/
Caused by: java.lang.IllegalStateException: Fail to execute DROP INDEX group_roles_resource
        at org.sonar.server.platform.db.migration.step.DdlChange$ContextImpl.execute(
        at org.sonar.server.platform.db.migration.step.DdlChange$ContextImpl.execute(
        at org.sonar.server.platform.db.migration.step.DdlChange$ContextImpl.execute(
        at org.sonar.server.platform.db.migration.version.v83.grouproles.DropResourceIdFromGroupRolesTable.execute(
        at org.sonar.server.platform.db.migration.step.DdlChange.execute(
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(
        ... 9 common frames omitted
Caused by: java.sql.SQLException: ORA-01418: specified index does not exist

        at oracle.jdbc.driver.T4CTTIoer11.processError(
        at oracle.jdbc.driver.T4CTTIoer11.processError(
        at oracle.jdbc.driver.T4C8Oall.processError(
        at oracle.jdbc.driver.T4CTTIfun.receive(
        at oracle.jdbc.driver.T4CTTIfun.doRPC(
        at oracle.jdbc.driver.T4C8Oall.doOALL(
        at oracle.jdbc.driver.T4CStatement.doOall8(
        at oracle.jdbc.driver.T4CStatement.doOall8(
        at oracle.jdbc.driver.T4CStatement.executeForRows(
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(
        at oracle.jdbc.driver.OracleStatement.executeInternal(
        at oracle.jdbc.driver.OracleStatement.execute(
        at oracle.jdbc.driver.OracleStatementWrapper.execute(
        at org.apache.commons.dbcp2.DelegatingStatement.execute(
        at org.apache.commons.dbcp2.DelegatingStatement.execute(
        at org.sonar.server.platform.db.migration.step.DdlChange$ContextImpl.execute(
        ... 14 common frames omitted
Caused by: oracle.jdbc.OracleDatabaseException: ORA-01418: specified index does not exist

I also checked the Oracle DB and i saw the the Indexes don’t exists on that Table. We tried to manually create those indexes but that does not work.
After that we removed the Removed the column ‘resource_id’ in ‘group_roles’ and restartet the DB migration process. The Problem stay’s the same.

Any Hints or Ideas what we could try next to solve this?

I have tried a few more steps. Deleted table manually and adjusted count in migration table. But it then continues from error to error.
It seems that there is something wrong inside the database. E.g. it searches for the trigger
but in the database the trigger is called

I have also renamed these triggers, then the process continues until the next error.
Is there a script from Sonarsource or tool with which I can check the database that all tables, indexes and triggers are correct?

Hey @steveda86,

It looks like your DB is in an inconsistent state.

When you say that you deleted the table - are you talking about the group_roles table? If that’s the case, then that wouldn’t be correct, as migration 3307 is about dropping a column on the table (and not the whole table).

A workaround could be to follow this procedure to mimic this migration step yourself (manually removing the resource_id column in group_roles table). If you’d like to do this, please follow these steps in order:

  1. Backup your 7.9.4 database

  2. Run the migrations directly from SQ until this point (migration 3307) where it fails

  3. Execute migration 3307 manually, omitting the step to drop the group_roles_resource index:
    a. Drop the uniq_group_roles index
    DROP INDEX uniq_group_roles
    b. Remove the resource_id column
    ALTER TABLE group_roles SET UNUSED (resource_id)
    c. Create the new index uniq_group_roles
    CREATE UNIQUE INDEX uniq_group_roles ON group_roles (organization_uuid, group_id, component_uuid, role)

  4. If everything went well until this step, you can omit this migration step by running:
    INSERT INTO schema_migrations ('version') VALUES('3307')

  5. Commit the insert if you don’t have an auto-commit mechanism.

  6. Restart SonarQube, the migration should resume to the next migration step

If after migration 3307 you encounter an issue with another migration, please share the logs with us and we’ll help you from there.


Hi @Belen_Pruvost

That was just an example of one of the steps who are failing.
The follwing steps are all failing

#3204 ‘Rename table ‘PROJECTS’ to ‘COMPONENTS’’ failed
#3307 ‘Remove column ‘resource_id’ in ‘group_roles’’ failed
#3310 ‘Remove column ‘resource_id’ in ‘user_roles’’ failed
#3311 ‘Remove column ‘id’ in ‘components’’ failed
#3492 ‘Drop primary key on ‘ID’ column of ‘PERM_TEMPLATES_GROUPS’ table’ failed
#3504 ‘Drop primary key on ‘ID’ column of ‘PERM_TEMPLATES_USERS’ table’ failed
#3573 ‘Drop primary key on ‘ID’ column of ‘PERMISSION_TEMPLATES’ table’ failed
#3679 ‘Drop column ‘templateId’ column for ‘RULES’’ failed

I tried to do this steps manually (drop coulm, drop prim-key and so on)
Sometime the Triggers had different names, and sometimes the Triggert didnt even exists in the Oracle Database.
Also on some steps i got the error that the specified index does not exist.

Sure i can try to fix all those problems manually.
But for me it looks like there are too many steps not working and it looks like our Database is broken. So is there a script or an SQL Command to check the consistency of this database?

Hi @steveda86 ,

There is no script - but you could manually compare your current schema with the schema-sq.ddl file for 8.9.

hi, this make no sense! i’m on version 7.9.4. i need to fix this Database Schema before i can upgrade to 8.9.
it makes no sense to compare my 7.9 database with the 8.9 schema.


This file is not available for 7.9 (it have been introduced with 8.0).

When the migration is failing at the step 3204, it means your database is upgrading from 8.1 to 8.2. So at this specific step, you can compare your schema with SQ 8.1.

1 Like