cashmusic/DIY — Issue #150: db type conversion script
Author: jessevondoom
Created: 2011-12-07 08:23:00+00:00
State: open
Labels: critical

For migrating from the current database to a different format. Supporting sqlite and MySQL. Should write a little logic to make it go both ways, but the real use-case is to allow basic install with sqlite only, then upgrade later from the admin. Much cleaner, and easier for less technical users.

I'm thinking something like this.

Grab the tables from the destination, empty and prep the destination:
```php
query("show tables");
$tables = $result->fetchAll(PDO::FETCH_COLUMN, 0);

$destDB->execute(SQL file from settings directory);
?>
```

Then an approach similar to this solution:
http://stackoverflow.com/questions/3795789/php-pdo-mysql-backup-to-remote-host

The major change I'd make to that code is to use prepared statements over trying to write the queries manually. But otherwise doing a big transaction that we can back out of is smart.