Merge lp:~nick-moffitt/charms/precise/keystone/migrate-sqlite-to-mysql into lp:~charmers/charms/precise/keystone/trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~nick-moffitt/charms/precise/keystone/migrate-sqlite-to-mysql |
Merge into: | lp:~charmers/charms/precise/keystone/trunk |
Diff against target: |
141 lines (+81/-14) 1 file modified
hooks/keystone-hooks (+81/-14) |
To merge this branch: | bzr merge lp:~nick-moffitt/charms/precise/keystone/migrate-sqlite-to-mysql |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Adam Gandelman (community) | Needs Fixing | ||
charmers | Pending | ||
Review via email: mp+149334@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-02-19.
Description of the change
This change uses sqlfairy (http://
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.
Unmerged revisions
- 42. By Nick Moffitt
-
Moved sqlfairy installation insurance down to the db_changed hook, so that it happens only when it's needed.
This is in response to https://code.launchpad .net/~nick- moffitt/ charms/ precise/ keystone/ migrate- sqlite- to-mysql/ +merge/ 149334/ comments/ 327313 - 41. By Nick Moffitt
-
Fix the half-finished upgrade-charm work.
- 40. By Nick Moffitt
-
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.
Hey Nick-
Thanks for submitting. This is quite useful. Tested using a sqlite database /w a few thousand users and the migration worked great. I'm just a bit confused about the last bit WRT upgrade. The added 'apt-get' commands you added to the install hook, which currently isn't called on charm upgrade. Did you mean to add a new upgrade hook that re-runs apt-get update only?