Does SonarQube provide supported tooling to reverse a committed database schema migration?
0 reputation · 15 Nov 2020, 06:22 UTC
0 reputation · 15 Nov 2020, 06:22 UTC
I need to determine whether a committed SonarQube database schema migration can be reversed using supported tooling if an upgrade must be rolled back. The upgrade process applies forward schema changes automatically at startup and recommends a pre-upgrade database backup, but the available documentation does not state whether any command or administrative option can undo those changes after they are committed.
This assumes SonarQube 9.x or 10.x with an external database and no manual schema modifications. It is a design and operational question, not a report of a failed upgrade or an observed error.
Does SonarQube provide supported tooling to reverse a committed database schema migration? What conditions make a schema change irreversible? Is restoring the database from a pre-upgrade backup the only supported way to return to an earlier version after migration?
34775 reputation · 15 Nov 2020, 18:18 UTC
SonarQube does not provide supported tooling to reverse a committed database schema migration. The platform applies forward schema changes automatically at startup via Liquibase changelogs, but offers no administrative command or option to undo those changes after they are committed.
In SonarQube 9.x and 10.x with an external database, schema evolution is managed by Liquibase. During upgrade, Liquibase executes changelog files that modify the database structure. These changes are recorded in a DATABASECHANGELOG table, but this tracking serves to prevent re-application, not to enable rollback.
Restoring from a pre-upgrade database backup is the only documented and supported method to return to an earlier version after migration. The official upgrade documentation consistently recommends this approach, and no alternative procedure is provided in the administration guides.
DATABASECHANGELOG table to verify Liquibase-managed migrations.Always create a full database backup before upgrading SonarQube. This is the only guaranteed recovery path if an upgrade must be rolled back. Plan for this requirement in your deployment and disaster recovery procedures.
Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 15 Nov 2020, 11:32 UTC
One clarification worth separating: Liquibase changelogs may include rollback sections, and the DATABASECHANGELOG table records applied changesets, but neither gives operators a supported reverse path in SonarQube 9.x or 10.x. SonarQube treats schema migration as one-way at runtime; the tracking table exists to prevent duplicate application, not to drive rollback. Attempting manual liquibase rollback commands against the production database can desynchronize that tracking table and leave SonarQube unable to validate its schema on the next startup. For verification, inspect the changelog directory under sonar/conf/liquibase to confirm whether rollback blocks exist, but treat them as development artifacts only. The supported recovery boundary remains restoring a pre-upgrade backup and reverting to the previous SonarQube version.