Skip to content

Commit

Permalink
Make RENAME TABLE operations idempotent so that in case there's a
Browse files Browse the repository at this point in the history
failure of some kind we can restart the upgrade and it'll continue.
Fixes ticket #1325.
  • Loading branch information
bharat committed Sep 2, 2010
1 parent af3d5ac commit 70c8572
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion modules/gallery/helpers/gallery_installer.php
Expand Up @@ -550,7 +550,9 @@ static function upgrade($version) {
}

if ($version == 26) {
$db->query("RENAME TABLE {failed_logins} TO {failed_auths}");
if (in_array("failed_logins", Database::instance()->list_tables())) {
$db->query("RENAME TABLE {failed_logins} TO {failed_auths}");
}
module::set_version("gallery", $version = 27);
}

Expand Down
4 changes: 3 additions & 1 deletion modules/rest/helpers/rest_installer.php
Expand Up @@ -35,7 +35,9 @@ static function install() {
static function upgrade($version) {
$db = Database::instance();
if ($version == 1) {
$db->query("RENAME TABLE {user_access_tokens} TO {user_access_keys}");
if (in_array("user_access_tokens", Database::instance()->list_tables())) {
$db->query("RENAME TABLE {user_access_tokens} TO {user_access_keys}");
}
module::set_version("rest", $version = 2);
}

Expand Down

0 comments on commit 70c8572

Please sign in to comment.