Chromium Code Reviews| Index: components/webdata/common/web_database.cc |
| diff --git a/components/webdata/common/web_database.cc b/components/webdata/common/web_database.cc |
| index 202829052c5cb0564ae73bc41aba7e1e93843260..b1545ab42021dddbae9165b482687a14dbb5c3d5 100644 |
| --- a/components/webdata/common/web_database.cc |
| +++ b/components/webdata/common/web_database.cc |
| @@ -14,11 +14,11 @@ |
| // corresponding changes must happen in the unit tests, and new migration test |
| // added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|. |
| // static |
| -const int WebDatabase::kCurrentVersionNumber = 57; |
| +const int WebDatabase::kCurrentVersionNumber = 58; |
| namespace { |
| -const int kCompatibleVersionNumber = 57; |
| +const int kCompatibleVersionNumber = 58; |
| // Change the version number and possibly the compatibility version of |
| // |meta_table_|. |
| @@ -155,10 +155,18 @@ sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded() { |
| for (int next_version = current_version + 1; |
| next_version <= kCurrentVersionNumber; |
| ++next_version) { |
| + |
| + // Do any database-wide migrations. |
| + bool update_compatible_version = false; |
| + if (!MigrateToVersion(next_version, &update_compatible_version)) |
| + return FailedMigrationTo(next_version); |
| + |
| + ChangeVersion(&meta_table_, next_version, update_compatible_version); |
| + |
| // Give each table a chance to migrate to this version. |
| for (TableMap::iterator it = tables_.begin(); it != tables_.end(); ++it) { |
| // Any of the tables may set this to true, but by default it is false. |
| - bool update_compatible_version = false; |
| + update_compatible_version = false; |
| if (!it->second->MigrateToVersion(next_version, |
| &update_compatible_version)) { |
| return FailedMigrationTo(next_version); |
| @@ -169,3 +177,29 @@ sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded() { |
| } |
| return sql::INIT_OK; |
| } |
| + |
| +bool WebDatabase::MigrateToVersion(int version, |
| + bool* update_compatible_version) { |
| + // Migrate if necessary. |
| + switch (version) { |
| + case 58: |
| + *update_compatible_version = true; |
| + return MigrateToVersion58DropWebAppsAndIntents(); |
| + } |
| + |
| + return true; |
| +} |
| + |
| +bool WebDatabase::MigrateToVersion58DropWebAppsAndIntents() { |
| + sql::Transaction transaction(&db_); |
| + return transaction.Begin() && |
| + (!db_.DoesTableExist("web_apps") || |
| + db_.Execute("DROP TABLE web_apps")) && |
|
Scott Hess - ex-Googler
2014/07/10 01:55:53
This and the others should be like:
db_.Execute(
Cait (Slow)
2014/07/14 23:09:45
Done.
|
| + (!db_.DoesTableExist("web_app_icons") || |
| + db_.Execute("DROP TABLE web_app_icons")) && |
| + (!db_.DoesTableExist("web_intents") || |
| + db_.Execute("DROP TABLE web_intents")) && |
| + (!db_.DoesTableExist("web_intents_defaults") || |
| + db_.Execute("DROP TABLE web_intents_defaults")) && |
| + transaction.Commit(); |
| +} |