For checking the quality of my private programming code, I have been using the free edition of SonarQube for multiple years. It is actually a cool project with a massive flaw: They did allow to use MySQL as Database - but not MariaDB. This struggle kept me a bit at bay, as I parted with MySQL years ago - with this one exception.
Some days ago I then stumbled upon the anouncement of SonarQube that did not fix this long-standing issue, but will be parting completly from MySQL. So the only choice would be to migrate to Oracle, MS SQL or PostgreSQL.
They even provided a tool called mysql-migrator for this purpose. However, this did not work. It always kept on complaining that it could not detect the schema version, etc.
Long story short: If you want (or in my case must...) switch from MySQL to PostgreSQL, use pgloader, which is available as Ubuntu package - all infos here.
I just installed a fresh PostgreSQL 9.6 in Docker, bundeled it with the postgres 9.6 alpine, fired it up and then migrated it with the following command:
pgloader mysql://<mysqluser>:<mysqlpassword>@<mysqlserverip>:3306/sonar pgsql://<psqluser>:<psqlpassword>@1<psqlserverip>/sonar
Due to all things Docker, one had to play a bit around with the correct IPs, Ports and permissions to get the tool working, but once that was said and done, everything worked fine:
table name read imported errors total time ------------------------------ --------- --------- --------- -------------- fetch meta data 180 180 0 0.357s Create Schemas 0 0 0 0.001s Create SQL Types 0 0 0 0.004s Create tables 106 106 0 2.842s Set Table OIDs 53 53 0 0.015s ------------------------------ --------- --------- --------- -------------- sonar.active_rules 1993 1993 0 0.116s sonar.active_rule_parameters 268 268 0 0.107s sonar.ce_activity 1 1 0 0.074s sonar.ce_scanner_context 0 0 0 0.040s sonar.ce_task_input 0 0 0 0.025s sonar.analysis_properties 0 0 0 0.157s sonar.duplications_index 0 0 0 0.020s sonar.events 349 349 0 0.173s sonar.groups 2 2 0 0.330s sonar.group_roles 12 12 0 0.433s sonar.ce_queue 0 0 0 0.033s sonar.issues 7508 7508 0 1.546s sonar.ce_task_characteristics 0 0 0 0.029s sonar.default_qprofiles 9 9 0 0.162s sonar.es_queue 0 0 0 0.143s sonar.file_sources 500 500 0 1.733s sonar.loaded_templates 13 13 0 1.498s sonar.metrics 246 246 0 1.564s sonar.organizations 1 1 0 1.744s sonar.org_qprofiles 26 26 0 1.722s sonar.perm_templates_groups 4 4 0 1.724s sonar.groups_users 3 3 0 1.283s sonar.perm_tpl_characteristics 0 0 0 1.673s sonar.projects 542 542 0 1.850s sonar.internal_properties 2 2 0 1.384s sonar.issue_changes 501 501 0 1.522s sonar.manual_measures 0 0 0 1.306s sonar.notifications 0 0 0 1.297s sonar.organization_members 2 2 0 1.504s sonar.project_links 0 0 0 1.532s sonar.permission_templates 1 1 0 1.453s sonar.project_qprofiles 0 0 0 1.483s sonar.perm_templates_users 0 0 0 1.417s sonar.qprofile_changes 2001 2001 0 1.616s sonar.plugins 13 13 0 1.366s sonar.qprofile_edit_users 0 0 0 1.545s sonar.project_branches 3 3 0 1.356s sonar.quality_gate_conditions 4 4 0 1.353s sonar.rules_metadata 1763 1763 0 1.311s sonar.project_measures 35940 35940 0 1.792s sonar.rules_profiles 26 26 0 1.503s sonar.schema_migrations 495 495 0 1.369s sonar.users 3 3 0 1.497s sonar.user_tokens 5 5 0 1.489s sonar.properties 8 8 0 0.941s sonar.qprofile_edit_groups 0 0 0 0.924s sonar.quality_gates 1 1 0 0.834s sonar.rules 1866 1866 0 1.069s sonar.rules_parameters 278 278 0 1.021s sonar.rule_repositories 21 21 0 0.999s sonar.snapshots 280 280 0 1.047s sonar.user_roles 0 0 0 0.960s sonar.webhook_deliveries 0 0 0 0.942s ------------------------------ --------- --------- --------- -------------- COPY Threads Completion 4 4 0 3.049s Create Indexes 127 127 0 22.308s Index Build Completion 127 127 0 1.460s Reset Sequences 33 33 0 0.051s Primary Keys 51 51 0 0.051s Create Foreign Keys 0 0 0 0.000s Create Triggers 0 0 0 0.001s Install Comments 0 0 0 0.000s ------------------------------ --------- --------- --------- -------------- Total import time 54690 54690 0 8.412s
This did not work for me to migrate the data from SonarQube 6.7.7 MySQL to PostgreSQL but I got it working using the migrator tool from https://github.com/SonarSource/mysql-migrator
Thanks for your inputs and glad it worked out in the end - even though it did not worked as described. I am a bit sad that I forgot to write the exact program versions I used during that time, but considering the fact that I did this back in 2019, I guess the mysql-migrator Tool from SonarQube has become better, which I good to know 🙂