diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..4a98044 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "database/migrate-mysql-to-postgres/mysql-postgresql-converter"] + path = database/migrate-mysql-to-postgres/mysql-postgresql-converter + url = https://github.com/lanyrd/mysql-postgresql-converter.git diff --git a/database/migrate-mysql-to-postgres/README.md b/database/migrate-mysql-to-postgres/README.md new file mode 100644 index 0000000..fa32993 --- /dev/null +++ b/database/migrate-mysql-to-postgres/README.md @@ -0,0 +1,98 @@ +***The following howto assumes that you are running Debian 7 (wheezy)*** + +# Stop Gitlab + +```bash +service gitlab stop +``` + +# Install postgresql + +```bash +sudo apt-get install -y postgresql-9.1 postgresql-client libpq-dev +``` + +# Initial Setup + +The following initial setup was taken from installation.md from the main installtion doc + +```bash +# Login to PostgreSQL +sudo -u postgres psql -d template1 + +# Create a user for GitLab. +template1=# CREATE USER git; + +# Create the GitLab production database & grant all privileges on database +template1=# CREATE DATABASE gitlabhq_production OWNER git; + +# Quit the database session +template1=# \q + +# Try connecting to the new database with the new user +sudo -u git -H psql -d gitlabhq_production +``` + +# Install postgres gem + +```bash +cd ~git/gitlab +sudo -u git -H bundle install --deployment --without development test mysql aws +``` + +# Dump the mysql database + +Make sure you do this as root, and therefore you will also need the root password for mysql as well + +```bash +mysqldump --compatible=postgresql --default-character-set=utf8 -r /tmp/gitlabhq_production.mysql -u root -p gitlabhq_production +``` + +# Convert the mysql to postgres import + +```bash +wget https://raw.github.com/lanyrd/mysql-postgresql-converter/master/db_converter.py -O /tmp/db_converter.py +python /tmp/db_converter.py /tmp/gitlab_production.mysql /tmp/gitlab_production.psql +``` + +***Note:*** This was tested using debian 7, with python 2.7.3 + +# Import the database + +```bash +sudo -u git -H psql -d gitlabhq_production -f /tmp/gitlab_production.psql +``` + +# Update database config + +```bash +cd ~git/gitlab/config +sudo -u git -H cp database.yml database.yml.backup +sudo -u git -H cp database.yml.postgresql database.yml +``` + +The defaults from the database.yml should work if you have not made any modifications to the postgres authentication. You may need to change database.yml to suite your config. + +# Start Gitlab service + +```bash +service gitlab start +service nginx restart +``` + +# Check application Status + +Check if GitLab and its environment are configured correctly: + +```bash +cd ~git/gitlab +sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production +``` + +To make sure you didn't miss anything run a more thorough check with: + +```bash +cd ~git/gitlab +sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production +``` + diff --git a/database/migrate-mysql-to-postgres/mysql-postgresql-converter b/database/migrate-mysql-to-postgres/mysql-postgresql-converter new file mode 160000 index 0000000..3aef484 --- /dev/null +++ b/database/migrate-mysql-to-postgres/mysql-postgresql-converter @@ -0,0 +1 @@ +Subproject commit 3aef484c05485d3653680b7aae7cd65dc4cd01b7