Skip to content

Postgresql Migration Process Notes

Halsey Burgund edited this page Jan 22, 2016 · 4 revisions

This page is to help figure out the best process for upgrading from the MySQL version of RW to the Postgresql version. The goal is to provide a reasonable upgrade path that migrates the codebase and existing databases to the new Postgresql-based system.

The primary code for this upgrade is in thespeaker-polygon branch of the LostItem fork of Roundware:

https://github.com/LostItem/roundware-server/tree/feature/speaker-polygons

Basic Process Overview

  1. Dump data to fixture using django dumpdata from most recent MySQL-based commit
  2. Update to initial Postgres commit (i.e. no schema changes yet) update dependencies and loaddata fixture
  3. Update to newest Postgres commit and perform data and schema migrations

Manual Process for Vagrant VM testing

Preparation

  • dump data from current production install
sudo su - roundware -c "/var/www/roundware/source/roundware/manage.py dumpdata rw > ~/rw-pre-postgres.json"

Vagrant Steps

  • git checkout develop c71270b (will create tag for proper commit: pre-postgres)
  • vagrant up
  • update server to initial postgres version before any schema changes: git checkout psql-conversion [75bb793]
  • vagrant ssh
  • install dependencies (should these be incorporated into the code for the tag and run using vagrant provision?)
sudo apt-get install binutils libproj-dev gdal-bin postgresql-server-dev-9.3 postgresql-9.3-postgis-2.1 libgdal-dev
sudo pip install psycopg2 geopy 

(should we include pip requirements updates in this commit so only have to run pip install -r requirements/common.txt?)

  • vagrant provision (mainly/exclusively to perform postgres config stuff; manage.py migrate needs to be run as well)
  • import dumped db into postgres db: python manage.py loaddata rw-pre-postgres.json
  • update to feature/speaker-polygons branch: git checkout feature/speaker-polygons (need to create specific commit tag once code is cleaned up)
  • run pip installs: pip install -r requirements/common.txt --upgrade
  • apply new migrations: python manage.py migrate
  • ./runserver.sh

Not verified yet

  • update to commit with schema clean-up migrations and admin changes: git checkout postgres-final ** removing speaker fields: mindistance maxdistance latitude longitude from models.py and admin.py

Production Server Process

Coming soon once we figure out the above...

Clone this wiki locally