Migrate from MySQL to Postgres

Currently on SonarQube 6.7. Will be upgrading to 7.9 but want to migrate to Postgres first. We are using the community edition of SonarQube so the DB copy tool is not available to us. What are our other options?

Hi Jed,

We do offer a FOSS migrator. You’ll find the details here:

Hi. I’ve read through the migration instructions and I’m a bit confused about the following statements.

  • SonarQube version 6.7LTS to 7.8
    Note: Your source and target databases must be using the same version of SonarQube.
  • Currently using MySQL

Migrating your database

Warning: do not run migration on live SonarQube instances.

  1. Start then stop the same version of SonarQube that you’re running on your source database on your target database. For example, if you’re running SonarQube 7.3 on your source database, run then stop SonarQube 7.3 on your target database.

We are currently on 6.7.x and have both development and production Sonar instances. We obviously will be upgrading dev first. Since we are migrating from MySql to Postgres, we don’t yet have a Postgres instance so I’m not sure what you mean by source and target database. All we have is the source – the MySQL database. Does the migration tool actual create the Postgres database itself or only migrate the data? If the latter, then I assume we create the Postgres instance first, which would be considered the target and then run the migration tool to copy the data over. If my assumption is not correct, can you please clarify the migration process regarding what you mean by the target database.

1 Like

Hello, you indeed need to create the postgreSQL database schema yourself. The SQ 6.7.X start&stop on that DB will create the tables SonarQube need. The migration tool only copy rows, that’s why you need to have the exact same database schema.

Thanks Pierre. One last question. How does simply stopping and starting Sonar 6.7 SQL Server DB create the Postgres schema? I imagine we have to do something first to force it to do that.

You need to create the schema yourself, with a tool or using sql query. Then you configure a SonarQube on it and start it, SonarQube will create the tables & index and insert some data.

As far as I know, you have to create a new instance and setup postgresql, sonarqube same version with the source one, then run a migration script.

Team,

Please clarify on the below process. We are also in the process of migrating SQ6.7.5 (mySql) to SQ7.9(PgSql). First, stop the existing instance SQ6.7.5. Then on the PgSql we need to create an empty DB (same name wherein Mysql), then start and stop new instance SQ7.9 where it creates tables and rows on Pgsql. Then we need to stop the new instance and run the db copy tool (https://github.com/SonarSource/mysql-migrator ) which performs the copy data from Mysql to PgSql. Once the copy is over we can start the SQ7.9 instance.

Assumptions: Above process performed on the same host and required configurations done wrt to Windows OS.

Is the above process is correct?

Or I need to configure SQ6.7.5 (existing instance) with PgSql. create the same schema name (of Mysql) then start and stop the SQ6.7.5 ( existing instance) where it created tables on PgSql…then using the migration tool copy data from mysql to PgSql, once data copy/migration done. Then we need to upgrade the target SQ6.7.5 to SQ7.9.

This is correct. You need the source schema and target schema to be on the same SQ version. So migrate to PostgesSQL first (with SQ 6.7.5), and once done you can upgrade SQ.

Awesome. I really appreciate your quick turn around. Thank you :slight_smile: .