Yikes.
Probably the cleanest solution is to:
- Initialize a new MySQL database for Gerrit using a temporary site.
*MAKE SURE YOU USE THE SAME VERSION OF GERRIT*
Just run the standard installation procedure to setup a
MySQL instance of Gerrit Code Review in a temporary site path.
You'll wind up with a clean database schema in your MySQL server,
and this dummy site directory directory you can clean up later.
- Purge out the system generated rows:
DELETE FROM schema_version;
DELETE FROM system_config;
DELETE FROM projects;
DELETE FROM ref_rights;
DELETE FROM account_groups;
DELETE FROM approval_categories;
DELETE FROM approval_category_values;
- Shutdown your PostgreSQL based Gerrit server.
- Dump each PostgreSQL table as a CSV file.
No clue how to do this easily, check the PostgreSQL documentation.
It may be a bit annoying to dump each table one at a time...
- Load each CSV file into MySQL.
- Reset the sequence counters in MySQL:
INSERT INTO account_group_id VALUES (SELECT MAX(account_group_id) + 1 FROM account_groups));
INSERT INTO account_id VALUES (SELECT MAX(account_id) + 1 FROM accounts));
INSERT INTO change_id VALUES (SELECT MAX(change_id) + 1 FROM changes));
INSERT INTO contributor_agreement_id VALUES (SELECT MAX(contributor_agreement_id) + 1 FROM contributor_agreements));
INSERT INTO change_message_id VALUES (....);
For that last one, you'll have to get the current counter from
PostgreSQL and fill in the ... by hand with the counter value:
SELECT nextval('change_message_id');
- Update your server's gerrit.config and secure.config files to
use the MySQL database parameters.
- Restart your Gerrit server.
- You should now be able to delete that temporary site you created
in the first step.
I've never tried this procedure myself. But in theory it should
work. Just watch out for the CSV dump-load process to make sure
they are using the same escaping rules for data values, same table
column orderings, and that you got every table in the schema.