diff options
author | Sytse Sijbrandij <sytse@gitlab.com> | 2014-05-29 16:58:48 +0000 |
---|---|---|
committer | Sytse Sijbrandij <sytse@gitlab.com> | 2014-05-29 16:58:48 +0000 |
commit | 5e20b0a73c51f8d480a94a384301135e765b0ad6 (patch) | |
tree | dbef95c1c57fd833b5e7ed64f326f96caba8f142 /doc | |
parent | e6beb6090320d6756369934c5151e36429c5d5f1 (diff) | |
parent | bc62c283c6f769a8f82842d13e909209296c4d3b (diff) | |
download | gitlab-ce-5e20b0a73c51f8d480a94a384301135e765b0ad6.tar.gz |
Merge branch 'new_index_converter' into 'master'
New index converter
Diffstat (limited to 'doc')
-rw-r--r-- | doc/update/mysql_to_postgresql.md | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/doc/update/mysql_to_postgresql.md b/doc/update/mysql_to_postgresql.md index acd1e33f599..5083bef1e26 100644 --- a/doc/update/mysql_to_postgresql.md +++ b/doc/update/mysql_to_postgresql.md @@ -34,21 +34,48 @@ 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 cd /tmp git clone https://github.com/gitlabhq/mysql-postgresql-converter.git -# Stash changes to db/schema.rb to make sure we can find the right index statements cd /home/git/gitlab + +# Stash changes to db/schema.rb to make sure we can find the right index statements sudo -u git -H git stash -# Generate the `CREATE INDEX CONCURRENTLY` statements based on schema.rb -cd /tmp/mysql-to-postgresql-converter -ruby index_create_statements.rb /home/git/gitlab/db/schema.rb > index_create_statements.psql +# Generate add_index.rb +ruby /tmp/mysql-postgresql-converter/add_index_statements.rb db/schema.rb > /tmp/mysql-postgresql-converter/add_index.rb + +# Create the indexes +sudo -u git -H bundle exec rails runner -e production 'eval $stdin.read' < /tmp/mysql-postgresql-converter/add_index.rb +``` + +### For omnibus-gitlab installations + +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 +cd /tmp +/opt/gitlab/embedded/bin/git clone https://github.com/gitlabhq/mysql-postgresql-converter.git +cd /tmp/mysql-postgresql-converter + +# Download schema.rb.bundled if necessary +test -e /opt/gitlab/embedded/service/gitlab-rails/db/schema.rb.bundled || sudo /opt/gitlab/embedded/bin/curl -o /opt/gitlab/embedded/service/gitlab-rails/db/schema.rb.bundled https://gitlab.com/gitlab-org/gitlab-ce/raw/v6.9.1/db/schema.rb + +# Generate add_index.rb +/opt/gitlab/embedded/bin/ruby add_index_statements.rb /opt/gitlab/embedded/service/gitlab-rails/db/schema.rb.bundled > add_index.rb -# Execute the SQL statements against the GitLab database -sudo -u git psql -f index_create_statements.psql -d gitlabhq_production +# Create the indexes +/opt/gitlab/bin/gitlab-rails runner 'eval $stdin.read' < add_index.rb ``` ## Converting a GitLab backup file from MySQL to Postgres |