allow failed upgrades
This commit is contained in:
parent
b1c7c79b2c
commit
85fb34e20f
1 changed files with 6 additions and 3 deletions
|
@ -25,18 +25,21 @@ class Upgrade extends Extension {
|
|||
// now done again as v9 with PDO
|
||||
|
||||
if($config->get_int("db_version") < 8) {
|
||||
// if this fails, don't try again
|
||||
$config->set_bool("in_upgrade", true);
|
||||
$config->set_int("db_version", 8);
|
||||
|
||||
$database->execute($database->engine->scoreql_to_sql(
|
||||
"ALTER TABLE images ADD COLUMN locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N"
|
||||
));
|
||||
|
||||
log_info("upgrade", "Database at version 8");
|
||||
$config->set_bool("in_upgrade", false);
|
||||
}
|
||||
|
||||
if($config->get_int("db_version") < 9) {
|
||||
$config->set_bool("in_upgrade", true);
|
||||
$config->set_int("db_version", 9);
|
||||
|
||||
if($database->db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
|
||||
$tables = $database->get_col("SHOW TABLES");
|
||||
foreach($tables as $table) {
|
||||
|
@ -44,18 +47,18 @@ class Upgrade extends Extension {
|
|||
$database->execute("ALTER TABLE $table TYPE=INNODB");
|
||||
}
|
||||
}
|
||||
$config->set_int("db_version", 9);
|
||||
|
||||
log_info("upgrade", "Database at version 9");
|
||||
$config->set_bool("in_upgrade", false);
|
||||
}
|
||||
|
||||
if($config->get_int("db_version") < 10) {
|
||||
$config->set_bool("in_upgrade", true);
|
||||
$config->set_int("db_version", 10);
|
||||
|
||||
log_info("upgrade", "Adding foreign keys to images");
|
||||
$database->Execute("ALTER TABLE images ADD CONSTRAINT foreign_images_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT");
|
||||
|
||||
$config->set_int("db_version", 10);
|
||||
log_info("upgrade", "Database at version 10");
|
||||
$config->set_bool("in_upgrade", false);
|
||||
}
|
||||
|
|
Reference in a new issue