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

Unified Diff: chrome/browser/webdata/web_database.cc

Issue 3239006: Fix credit card table migration step. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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
« no previous file with comments | « chrome/browser/webdata/web_database.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/webdata/web_database.cc
===================================================================
--- chrome/browser/webdata/web_database.cc (revision 57824)
+++ chrome/browser/webdata/web_database.cc (working copy)
@@ -446,16 +446,18 @@
}
// Initialize the tables.
+ bool credit_card_table_created = false;
if (!InitKeywordsTable() || !InitLoginsTable() || !InitWebAppIconsTable() ||
!InitWebAppsTable() || !InitAutofillTable() ||
!InitAutofillDatesTable() || !InitAutoFillProfilesTable() ||
- !InitCreditCardsTable() || !InitTokenServiceTable()) {
+ !InitCreditCardsTable(&credit_card_table_created) ||
+ !InitTokenServiceTable()) {
LOG(WARNING) << "Unable to initialize the web database.";
return sql::INIT_FAILURE;
}
// If the file on disk is an older database version, bring it up to date.
- MigrateOldVersionsAsNeeded();
+ MigrateOldVersionsAsNeeded(credit_card_table_created);
return transaction.Commit() ? sql::INIT_OK : sql::INIT_FAILURE;
}
@@ -759,7 +761,7 @@
return true;
}
-bool WebDatabase::InitCreditCardsTable() {
+bool WebDatabase::InitCreditCardsTable(bool* table_was_created) {
if (!db_.DoesTableExist("credit_cards")) {
if (!db_.Execute("CREATE TABLE credit_cards ( "
"label VARCHAR, "
@@ -777,6 +779,7 @@
NOTREACHED();
return false;
}
+ *table_was_created = true;
if (!db_.Execute("CREATE INDEX credit_cards_label_index "
"ON credit_cards (label)")) {
NOTREACHED();
@@ -1870,7 +1873,7 @@
return false;
}
-void WebDatabase::MigrateOldVersionsAsNeeded() {
+void WebDatabase::MigrateOldVersionsAsNeeded(bool credit_card_table_created) {
// Migrate if necessary.
int current_version = meta_table_.GetVersionNumber();
switch (current_version) {
@@ -1907,19 +1910,22 @@
// FALL THROUGH
case 22:
- // Add the card_number_encrypted column.
- if (!db_.Execute("ALTER TABLE credit_cards ADD COLUMN "
- "card_number_encrypted BLOB DEFAULT NULL")) {
- NOTREACHED();
- LOG(WARNING) << "Unable to update web database to version 23.";
- return;
+ // Add the card_number_encrypted column if credit card table was not
+ // created in this build.
+ if (!credit_card_table_created) {
+ if (!db_.Execute("ALTER TABLE credit_cards ADD COLUMN "
+ "card_number_encrypted BLOB DEFAULT NULL")) {
+ NOTREACHED();
+ LOG(WARNING) << "Unable to update web database to version 23.";
+ return;
+ }
+ if (!db_.Execute("ALTER TABLE credit_cards ADD COLUMN "
+ "verification_code_encrypted BLOB DEFAULT NULL")) {
+ NOTREACHED();
+ LOG(WARNING) << "Unable to update web database to version 23.";
+ return;
+ }
}
- if (!db_.Execute("ALTER TABLE credit_cards ADD COLUMN "
- "verification_code_encrypted BLOB DEFAULT NULL")) {
- NOTREACHED();
- LOG(WARNING) << "Unable to update web database to version 23.";
- return;
- }
meta_table_.SetVersionNumber(23);
// FALL THROUGH
« no previous file with comments | « chrome/browser/webdata/web_database.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698