*Make sure you view this [guide from the `master` branch](../../../master/doc/update/mysql_to_postgresql.md) for the most up to date instructions.*
*Make sure you view this [guide from the `master` branch](../../../master/doc/update/mysql_to_postgresql.md) for the most up to date instructions.*
If you are replacing MySQL with Postgres while keeping GitLab on the same server all you need to do is to export from MySQL, import into Postgres and rebuild the indexes as described below. If you are also moving GitLab to another server, or if you are switching to omnibus-gitlab, you may want to use a GitLab backup file. The second part of this documents explains the procedure to do this.
If you are replacing MySQL with Postgres while keeping GitLab on the same server all you need to do is to export from MySQL, convert the resulting SQL file, and import it into Postgres. If you are also moving GitLab to another server, or if you are switching to omnibus-gitlab, you may want to use a GitLab backup file. The second part of this documents explains the procedure to do this.
# Install gems for PostgreSQL (note: the line below states '--without ... mysql')
# Install gems for PostgreSQL (note: the line below states '--without ... mysql')
sudo -u git -H bundle install --without development test mysql --deployment
sudo -u git -H bundle install --without development test mysql --deployment
...
@@ -28,51 +26,6 @@ sudo -u git -H bundle install --without development test mysql --deployment
...
@@ -28,51 +26,6 @@ sudo -u git -H bundle install --without development test mysql --deployment
sudo service gitlab start
sudo service gitlab start
```
```
## Rebuild indexes
The lanyrd database converter script does not preserve all indexes, so we have to recreate them ourselves after migrating from MySQL. It is not necessary to shut down GitLab for this process.
### For non-omnibus installations
On non-omnibus installations (distributed using Git) we retrieve the index declarations from version control using `git stash`.
```
# Clone the database converter on your Postgres-backed GitLab server
On omnibus-gitlab we need to get the index declarations from a file called `schema.rb.bundled`. For versions older than 6.9, we need to download the file.
```
# Clone the database converter on your Postgres-backed GitLab server