Execution of migration step #2001 'Add scope to rules' failed

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    7.0 to 7.9.2
  • what are you trying to achieve
    upgrade from 7.0 to 7.9.2
  • what have you tried so far to achieve this
    Followed: https://docs.sonarqube.org/7.9/setup/upgrading/
    But when i get to the host_url/setup step, the database migration fails.
2020.01.22 21:34:53 INFO  web[][o.s.p.ProcessEntryPoint] Starting web
2020.01.22 21:34:54 INFO  web[][o.a.t.u.n.NioSelectorPool] Using a shared selector for servlet write/read
2020.01.22 21:34:54 INFO  web[][o.s.c.e.CoreExtensionsLoader] Loaded core extensions: enterprise-edition, ce-workers, developer-scanner, developer-server, governance, license, securityreport
2020.01.22 21:34:55 INFO  web[][o.e.p.PluginsService] no modules loaded
2020.01.22 21:34:55 INFO  web[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.join.ParentJoinPlugin]
2020.01.22 21:34:55 INFO  web[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.percolator.PercolatorPlugin]
2020.01.22 21:34:55 INFO  web[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
2020.01.22 21:34:56 INFO  web[][o.s.s.e.EsClientProvider] Connected to local Elasticsearch: [127.0.0.1:8501]
2020.01.22 21:34:56 INFO  web[][o.s.s.p.LogServerVersion] SonarQube Server / 7.9.2.30863 / cd30425aa0b4e62c39b57c81d64be16e365f6d83
2020.01.22 21:34:56 INFO  web[][o.sonar.db.Database] Create JDBC data source for \
2020.01.22 21:34:57 INFO  web[][o.s.s.p.ServerFileSystemImpl] SonarQube home: /app/sonar/application/sonarqube-7.9.2
2020.01.22 21:34:57 INFO  web[][o.s.s.u.SystemPasscodeImpl] System authentication by passcode is disabled
2020.01.22 21:34:58 WARN  web[][o.s.s.p.DatabaseServerCompatibility] The database must be manually upgraded. Please backup the database and browse /setup. For more information: https://docs.sonarqube.org/latest/setup/upgrading
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin Git / 1.8.0.1574 / aec3dc8f5228aabd218e1cd31ac6e6515a43715d
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin GitHub Authentication for SonarQube / 1.5.0.870 / 153f7c7af7a264adb0fcbe5fee87bdd140a6a3a1
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin JaCoCo / 1.0.2.475 / b79a4724f3a9af1051266b4f8ca0460977295ead
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin LDAP / 2.2.0.608 / 79dc3fa4393a29667673c70182f3016288b548b7
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SAML 2.0 Authentication for SonarQube / 1.1.0.181 / 16fcb5be2d3bcfee8920b29cd758d8b957a18acb
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarABAP / 3.8.0.2034 / 2904652c6ef4863eaace62c40fec0512724430e4
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarApex / 1.5.0.315 / 4ff3a145a58f3f84f1b39846a205a129d742e993
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarC# / 7.15.0.8572 / e0ad49e38a28a8fc333ba746fc998e48678f6a8b
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarCFamily / 6.3.0.11371 / 87798a096368f2cee97709b9d41b9c135ac2600c
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarCOBOL / 4.4.0.3403 / 87052f378052eedd582643a831d334123cf39965
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarCSS / 1.1.1.1010 / 365e21fd0cb9035669fc59f6fec7c8fd28a7303b
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarFlex / 2.5.1.1831 / a0c44437f6abb0feec76edd073f91fec64db2a6c
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarGo / 1.1.1.2000 / 40d55921c7a63b67386a053490d17b6723a46cd5
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarHTML / 3.1.0.1615 / 4181edb5eff5605bec82dc0aa15ecd70eaa5857f
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarJS / 5.2.1.7778 / 49f34eaeaad59868d4353d89b1fc5c02bbe51976
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarJava / 5.13.1.18282 / 568f8ed2349f48e250a9329895b9a870100dfbeb
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarKotlin / 1.5.0.315 / 4ff3a145a58f3f84f1b39846a205a129d742e993
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarPHP / 3.2.0.4868 / ec66bd5f8490677eb0ebae82aa17c2a5d9c0e5e7
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarPLI / 1.10.0.1880 / 1f78eb283a8d0c3e7f911f3259094c5696adad64
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarPLSQL / 3.4.1.2576 / a27e6384088454d7160dd39ea5ba54a9929c15f4
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarPython / 1.14.1.3143 / eed7b315b6116fe462a19c771013bf3891c92a97
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarRPG / 2.3.0.1187 / e0c75c815c1ae3955d823f1abcc8c1718b2d69f7
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarRuby / 1.5.0.315 / 4ff3a145a58f3f84f1b39846a205a129d742e993
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarScala / 1.5.0.315 / 4ff3a145a58f3f84f1b39846a205a129d742e993
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarSwift / 4.1.0.3087 / e71ead60ade025c4f22a8c29fc32ab7c90606ec9
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarTS / 1.9.0.3766 / 4a4080b78001a78d758d1d0fa0190fb9496b6f57
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarTSQL / 1.4.0.3334 / 7b4dc9eeb6301765e09583a3d570b5941223e0b4
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarVB / 7.15.0.8572 / e0ad49e38a28a8fc333ba746fc998e48678f6a8b
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarVB6 / 2.6.0.1875 / cfa6ee80615b98744158f3981fb29497101a03f5
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin SonarXML / 2.0.1.2020 / c5b84004face582d56f110e24c29bf9c6a679e69
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin Svn / 1.9.0.1295 / 942e075773975354e32691a60bfd968065703e04
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin Vulnerability Analysis / 7.9.0.5105 / 90f56794ddd2e4e4c4265743c44e508dfff03c32
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin Vulnerability Rules for C# / 7.9.0.5105 / 90f56794ddd2e4e4c4265743c44e508dfff03c32
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin Vulnerability Rules for Java / 7.9.0.5105 / 90f56794ddd2e4e4c4265743c44e508dfff03c32
2020.01.22 21:34:58 INFO  web[][o.s.s.p.ServerPluginRepository] Deploy plugin Vulnerability Rules for PHP / 7.9.0.5105 / 90f56794ddd2e4e4c4265743c44e508dfff03c32
2020.01.22 21:34:59 INFO  web[][o.s.s.p.d.m.c.MssqlCharsetHandler] Verify that database collation is case-sensitive and accent-sensitive
2020.01.22 21:34:59 INFO  web[][o.s.s.p.Platform] Database needs to be migrated. Please refer to https://docs.sonarqube.org/latest/setup/upgrading
2020.01.22 21:34:59 INFO  web[][o.s.s.p.w.MasterServletFilter] Initializing servlet filter org.sonar.server.ws.WebServiceFilter@4da4aa10 [pattern=UrlPattern{inclusions=[/api/system/migrate_db.*, ...], exclusions=[/api/properties*, ...]}]
2020.01.22 21:34:59 INFO  web[][o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 8590
2020.01.22 21:44:51 INFO  web[][o.s.s.p.d.m.DatabaseMigrationImpl] Starting DB Migration and container restart
2020.01.22 21:44:51 INFO  web[][DbMigrations] Executing DB migrations...
2020.01.22 21:44:51 INFO  web[][DbMigrations] #2001 'Add scope to rules'...
2020.01.22 21:44:51 ERROR web[][DbMigrations] #2001 'Add scope to rules': failure | time=21ms
2020.01.22 21:44:51 ERROR web[][DbMigrations] Executed DB migrations: failure | time=22ms
2020.01.22 21:44:51 ERROR web[][o.s.s.p.d.m.DatabaseMigrationImpl] DB migration failed | time=115ms
2020.01.22 21:44:51 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 #2001 'Add scope to rules' failed
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:79)
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:67)
        at java.base/java.lang.Iterable.forEach(Iterable.java:75)
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:52)
        at org.sonar.server.platform.db.migration.engine.MigrationEngineImpl.execute(MigrationEngineImpl.java:68)
        at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doUpgradeDb(DatabaseMigrationImpl.java:105)
        at org.sonar.server.platform.db.migration.DatabaseMigrationImpl.doDatabaseMigration(DatabaseMigrationImpl.java:80)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalStateException: Fail to execute ALTER TABLE rules ADD scope NVARCHAR (20) NULL
        at org.sonar.server.platform.db.migration.step.DdlChange$Context.execute(DdlChange.java:97)
        at org.sonar.server.platform.db.migration.step.DdlChange$Context.execute(DdlChange.java:77)
        at org.sonar.server.platform.db.migration.version.v71.AddRuleScope.execute(AddRuleScope.java:36)
        at org.sonar.server.platform.db.migration.step.DdlChange.execute(DdlChange.java:45)
        at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:75)
        ... 9 common frames omitted
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot find the object "rules" because it does not exist or you do not have permissions.
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1621)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:868)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:768)
        at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7194)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2935)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:248)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:223)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(SQLServerStatement.java:744)
        at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:175)
        at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:175)
        at org.sonar.server.platform.db.migration.step.DdlChange$Context.execute(DdlChange.java:82)

Hi,

You should double-check your connection string to make sure you’re connecting to the right schema and/or with the right credentials.

 
HTH,
Ann