-
Committer:
Nick Moffitt
-
Date:
2013-02-19 15:49:55 UTC
-
Revision ID:
nick.moffitt@canonical.com-20130219154955-7zdk15ji605a7twv
Automatically migrate the database schema and contents when moving from sqlite to mysql.
This change uses sqlfairy (http://packages.ubuntu.com/precise/libsql-translator-perl) to migrate the schema and then all rows from the default sqlite database over to the new database when the mysql relation fires for the first time. The rationale is that users may not realize that they're using sqlite until it's too late, and adding the relation caused a loss of all authentication data.
The SQL generated from sqlfairy needed some manipulation in order to work.
In particular:
* "UNIQUE `` (`name`)" commands needed a UID of some sort between the ``
for mysql to accept them
* As we're running these mysql 'LOAD DATA' commands from a remote
client, 'LOAD DATA INFILE' needed to become 'LOAD DATA LOCAL INFILE',
and the mysql client needed to be explicitly told to allow this
syntax.
The install hook edits configuration entries, risking loss of idempotence. Instead of just re-running it in the upgrade hook, I've replicated the apt-get commands.