make sure all tables are innodb, for foreign keys to work

This commit is contained in:
Shish 2009-12-30 08:48:40 +00:00
parent c9c4843e43
commit c9283ef010
3 changed files with 29 additions and 2 deletions

View File

@ -57,6 +57,10 @@ class AdminPage implements Extension {
$this->purge_unused_tags();
$redirect = true;
break;
case 'convert to innodb':
$this->convert_to_innodb();
$redirect = true;
break;
case 'database dump':
$this->dbdump($page);
break;
@ -142,6 +146,17 @@ class AdminPage implements Extension {
}
}
}
private function convert_to_innodb() {
global $database;
if($database->engine->name == "mysql") {
$tables = $database->db->MetaTables();
foreach($tables as $table) {
log_info("upgrade", "converting $table to innodb");
$database->execute("ALTER TABLE $table TYPE=INNODB");
}
}
}
}
add_event_listener(new AdminPage());
?>

View File

@ -40,6 +40,7 @@ class AdminPageTheme extends Themelet {
<option value='recount tag use'>Recount tag use</option>
<option value='purge unused tags'>Purge unused tags</option>
<option value='database dump'>Download database contents</option>
<option value='convert to innodb'>Convert database to InnoDB (MySQL only)</option>
</select>
<input type='submit' value='Go'>
</form>

View File

@ -18,10 +18,21 @@ class Upgrade implements Extension {
// cry :S
}
if($config->get_int("db_version") < 6) { // 7
// add column image->locked
if($config->get_int("db_version") < 7) {
if($database->engine->name == "mysql") {
$tables = $database->db->MetaTables();
foreach($tables as $table) {
log_info("upgrade", "converting $table to innodb");
$database->execute("ALTER TABLE $table TYPE=INNODB");
}
}
$config->set_int("db_version", 7);
log_info("Database at version 7");
}
// TODO:
// add column image->locked
}
}
add_event_listener(new Upgrade(), 5);
?>