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

Unified Diff: chrome/browser/history/android/android_urls_database.cc

Issue 10067030: Upgrade the history database to version 23 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Init Created 8 years, 8 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/android/android_urls_database.cc
diff --git a/chrome/browser/history/android/android_urls_database.cc b/chrome/browser/history/android/android_urls_database.cc
index 1527b6ac415d54603f1c36e2952362943f8b9b04..e602bc6b608d70da419d7ef9e1f3f021f41f7797 100644
--- a/chrome/browser/history/android/android_urls_database.cc
+++ b/chrome/browser/history/android/android_urls_database.cc
@@ -18,7 +18,7 @@ bool AndroidURLsDatabase::CreateAndroidURLsTable() {
const char* name = "android_urls";
if (!GetDB().DoesTableExist(name)) {
std::string sql;
- sql.append("CREATE TABLE ");
+ sql.append("CREATE TABLE IF NOT EXISTS ");
sky 2012/04/13 21:32:05 How come you need this if not exists? Doesn't line
michaelbai 2012/04/13 23:02:35 Yes, they are not needed. On 2012/04/13 21:32:05,
sql.append(name);
sql.append("("
"id INTEGER PRIMARY KEY,"
@@ -30,13 +30,13 @@ bool AndroidURLsDatabase::CreateAndroidURLsTable() {
return false;
}
- if (!GetDB().Execute("CREATE INDEX android_urls_raw_url_idx"
+ if (!GetDB().Execute("CREATE INDEX IF NOT EXISTS android_urls_raw_url_idx"
" ON android_urls(raw_url)")) {
LOG(ERROR) << GetDB().GetErrorMessage();
return false;
}
- if (!GetDB().Execute("CREATE INDEX android_urls_url_id_idx"
+ if (!GetDB().Execute("CREATE INDEX IF NOT EXISTS android_urls_url_id_idx"
" ON android_urls(url_id)")) {
LOG(ERROR) << GetDB().GetErrorMessage();
return false;
@@ -144,4 +144,25 @@ bool AndroidURLsDatabase::ClearAndroidURLRows() {
return GetDB().Execute("DELETE FROM android_urls");
}
+bool AndroidURLsDatabase::MigrateToVersion22() {
+ if (!GetDB().DoesTableExist("android_urls"))
+ return true;
+
+ if (!GetDB().Execute("ALTER TABLE android_urls RENAME TO android_urls_tmp"))
+ return false;
+
+ if (!CreateAndroidURLsTable())
+ return false;
+
+ if (!GetDB().Execute(
+ "INSERT INTO android_urls (id, raw_url, url_id) "
+ "SELECT id, raw_url, url_id FROM android_urls_tmp"))
+ return false;
+
+ if (!GetDB().Execute("DROP TABLE android_urls_tmp"))
+ return false;
+
+ return true;
+}
+
} // namespace history

Powered by Google App Engine
This is Rietveld 408576698