Added database upgrade script

upgrade-database.py detects the version of the database, and upgrades it
if necessary.
Merge remote-tracking branch 'upstream/master'
Fixed database upgrade bugs

upgrade-database is having strange issues with changes not occurring in
order, breaking the upgrade process if going across multiple versions.
Fixed by reopening database connection after each upgrade.
Merge pull request #5 from qwertyzzz18/database-upgrade-fix

Database upgrade fix