Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3268)

Unified Diff: chrome/browser/history/shortcuts_database.cc

Issue 134853004: Migrate old Shortcuts DB data to conform to new type values (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Peter's comments - 2 Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/history/shortcuts_database.cc
diff --git a/chrome/browser/history/shortcuts_database.cc b/chrome/browser/history/shortcuts_database.cc
index 51d6f09293fbffe58da621bfab05911739d5a9d8..1f7d8ef6973e8fc4b56e178630e23ba7dfb14934 100644
--- a/chrome/browser/history/shortcuts_database.cc
+++ b/chrome/browser/history/shortcuts_database.cc
@@ -11,11 +11,18 @@
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
+#include "sql/meta_table.h"
#include "sql/statement.h"
#include "sql/transaction.h"
namespace {
+// Current version number. We write databases at the "current" version number,
+// but any previous version that can read the "compatible" one can make do with
+// or database without *too* many bad effects.
Peter Kasting 2014/02/12 00:27:50 Nit: or -> our
Anuj 2014/02/12 23:54:40 Done.
+const int kCurrentVersionNumber = 1;
+const int kCompatibleVersionNumber = 1;
+
void BindShortcutToStatement(
const history::ShortcutsBackend::Shortcut& shortcut,
sql::Statement* s) {
@@ -196,6 +203,25 @@ bool ShortcutsDatabase::EnsureTable() {
transaction.Commit();
}
+ if (!sql::MetaTable::DoesTableExist(&db_)) {
+ meta_table_.Init(&db_, kCurrentVersionNumber, kCompatibleVersionNumber);
+ sql::Transaction transaction(&db_);
+ transaction.Begin();
Peter Kasting 2014/02/12 00:27:50 Nit: Include this call in the return statement Yo
Anuj 2014/02/12 23:54:40 Done.
+ return
+ // Migrate old SEARCH_OTHER_ENGINE values to the new type value.
+ db_.Execute(base::StringPrintf("UPDATE omni_box_shortcuts "
+ "SET type = 13 WHERE type = 9").c_str()) &&
+ // Migrate old EXTENSION_APP values to the new type value.
+ db_.Execute(base::StringPrintf("UPDATE omni_box_shortcuts "
+ "SET type = 14 WHERE type = 10").c_str()) &&
+ // Migrate old CONTACT values to the new type value.
+ db_.Execute(base::StringPrintf("UPDATE omni_box_shortcuts "
+ "SET type = 15 WHERE type = 11").c_str()) &&
+ // Migrate old BOOKMARK_TITLE values to the new type value.
+ db_.Execute(base::StringPrintf("UPDATE omni_box_shortcuts "
+ "SET type = 16 WHERE type = 12").c_str()) &&
+ transaction.Commit();
+ }
return true;
}

Powered by Google App Engine
This is Rietveld 408576698