Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/autofill/core/browser/webdata/autofill_table.h" | 5 #include "components/autofill/core/browser/webdata/autofill_table.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 return MigrateToVersion65AddServerMetadataTables(); | 464 return MigrateToVersion65AddServerMetadataTables(); |
| 465 case 66: | 465 case 66: |
| 466 *update_compatible_version = false; | 466 *update_compatible_version = false; |
| 467 return MigrateToVersion66AddCardBillingAddress(); | 467 return MigrateToVersion66AddCardBillingAddress(); |
| 468 case 67: | 468 case 67: |
| 469 *update_compatible_version = false; | 469 *update_compatible_version = false; |
| 470 return MigrateToVersion67AddMaskedCardBillingAddress(); | 470 return MigrateToVersion67AddMaskedCardBillingAddress(); |
| 471 case 70: | 471 case 70: |
| 472 *update_compatible_version = false; | 472 *update_compatible_version = false; |
| 473 return MigrateToVersion70AddSyncMetadata(); | 473 return MigrateToVersion70AddSyncMetadata(); |
| 474 case 71: | |
| 475 *update_compatible_version = false; | |
| 476 return MigrateToVersion71AddServerCardMetadataBillingAddress(); | |
| 474 } | 477 } |
| 475 return true; | 478 return true; |
| 476 } | 479 } |
| 477 | 480 |
| 478 bool AutofillTable::AddFormFieldValues( | 481 bool AutofillTable::AddFormFieldValues( |
| 479 const std::vector<FormFieldData>& elements, | 482 const std::vector<FormFieldData>& elements, |
| 480 std::vector<AutofillChange>* changes) { | 483 std::vector<AutofillChange>* changes) { |
| 481 return AddFormFieldValuesTime(elements, changes, Time::Now()); | 484 return AddFormFieldValuesTime(elements, changes, Time::Now()); |
| 482 } | 485 } |
| 483 | 486 |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1203 | 1206 |
| 1204 return s.Succeeded(); | 1207 return s.Succeeded(); |
| 1205 } | 1208 } |
| 1206 | 1209 |
| 1207 bool AutofillTable::GetServerCreditCards( | 1210 bool AutofillTable::GetServerCreditCards( |
| 1208 std::vector<std::unique_ptr<CreditCard>>* credit_cards) { | 1211 std::vector<std::unique_ptr<CreditCard>>* credit_cards) { |
| 1209 credit_cards->clear(); | 1212 credit_cards->clear(); |
| 1210 | 1213 |
| 1211 sql::Statement s(db_->GetUniqueStatement( | 1214 sql::Statement s(db_->GetUniqueStatement( |
| 1212 "SELECT " | 1215 "SELECT " |
| 1213 "card_number_encrypted, " // 0 | 1216 "card_number_encrypted, " // 0 |
| 1214 "last_four," // 1 | 1217 "last_four," // 1 |
| 1215 "masked.id," // 2 | 1218 "masked.id," // 2 |
| 1216 "metadata.use_count," // 3 | 1219 "metadata.use_count," // 3 |
| 1217 "metadata.use_date," // 4 | 1220 "metadata.use_date," // 4 |
| 1218 "type," // 5 | 1221 "type," // 5 |
| 1219 "status," // 6 | 1222 "status," // 6 |
| 1220 "name_on_card," // 7 | 1223 "name_on_card," // 7 |
| 1221 "exp_month," // 8 | 1224 "exp_month," // 8 |
| 1222 "exp_year," // 9 | 1225 "exp_year," // 9 |
| 1223 "billing_address_id " // 10 | 1226 "metadata.billing_address_id," // 10 |
| 1227 "masked.billing_address_id " // 11 | |
|
please use gerrit instead
2017/01/11 19:23:03
Why store billing address identifier in two differ
sebsg
2017/01/12 15:36:31
Right, I didn't realize I could just migrate the d
| |
| 1224 "FROM masked_credit_cards masked " | 1228 "FROM masked_credit_cards masked " |
| 1225 "LEFT OUTER JOIN unmasked_credit_cards USING (id) " | 1229 "LEFT OUTER JOIN unmasked_credit_cards USING (id) " |
| 1226 "LEFT OUTER JOIN server_card_metadata metadata USING (id)")); | 1230 "LEFT OUTER JOIN server_card_metadata metadata USING (id)")); |
| 1227 while (s.Step()) { | 1231 while (s.Step()) { |
| 1228 int index = 0; | 1232 int index = 0; |
| 1229 | 1233 |
| 1230 // If the card_number_encrypted field is nonempty, we can assume this card | 1234 // If the card_number_encrypted field is nonempty, we can assume this card |
| 1231 // is a full card, otherwise it's masked. | 1235 // is a full card, otherwise it's masked. |
| 1232 base::string16 full_card_number = UnencryptedCardFromColumn(s, index++); | 1236 base::string16 full_card_number = UnencryptedCardFromColumn(s, index++); |
| 1233 base::string16 last_four = s.ColumnString16(index++); | 1237 base::string16 last_four = s.ColumnString16(index++); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1254 // autodetected type. | 1258 // autodetected type. |
| 1255 card->SetTypeForMaskedCard(card_type.c_str()); | 1259 card->SetTypeForMaskedCard(card_type.c_str()); |
| 1256 } else { | 1260 } else { |
| 1257 DCHECK_EQ(CreditCard::GetCreditCardType(full_card_number), card_type); | 1261 DCHECK_EQ(CreditCard::GetCreditCardType(full_card_number), card_type); |
| 1258 } | 1262 } |
| 1259 | 1263 |
| 1260 card->SetServerStatus(ServerStatusStringToEnum(s.ColumnString(index++))); | 1264 card->SetServerStatus(ServerStatusStringToEnum(s.ColumnString(index++))); |
| 1261 card->SetRawInfo(CREDIT_CARD_NAME_FULL, s.ColumnString16(index++)); | 1265 card->SetRawInfo(CREDIT_CARD_NAME_FULL, s.ColumnString16(index++)); |
| 1262 card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++)); | 1266 card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++)); |
| 1263 card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(index++)); | 1267 card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(index++)); |
| 1268 | |
| 1269 // The billing address id from the metadata has priority, but if it's empty, | |
| 1270 // use the one from the masked_credit_cards table. | |
| 1264 card->set_billing_address_id(s.ColumnString(index++)); | 1271 card->set_billing_address_id(s.ColumnString(index++)); |
| 1272 if (card->billing_address_id().empty()) | |
| 1273 card->set_billing_address_id(s.ColumnString(index++)); | |
| 1274 | |
| 1265 credit_cards->push_back(std::move(card)); | 1275 credit_cards->push_back(std::move(card)); |
| 1266 } | 1276 } |
| 1267 | 1277 |
| 1268 return s.Succeeded(); | 1278 return s.Succeeded(); |
| 1269 } | 1279 } |
| 1270 | 1280 |
| 1271 void AutofillTable::SetServerCreditCards( | 1281 void AutofillTable::SetServerCreditCards( |
| 1272 const std::vector<CreditCard>& credit_cards) { | 1282 const std::vector<CreditCard>& credit_cards) { |
| 1273 sql::Transaction transaction(db_); | 1283 sql::Transaction transaction(db_); |
| 1274 if (!transaction.Begin()) | 1284 if (!transaction.Begin()) |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1301 masked_insert.BindString16(4, card.LastFourDigits()); | 1311 masked_insert.BindString16(4, card.LastFourDigits()); |
| 1302 masked_insert.BindString16(5, card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); | 1312 masked_insert.BindString16(5, card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); |
| 1303 masked_insert.BindString16(6, | 1313 masked_insert.BindString16(6, |
| 1304 card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 1314 card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
| 1305 masked_insert.BindString(7, card.billing_address_id()); | 1315 masked_insert.BindString(7, card.billing_address_id()); |
| 1306 | 1316 |
| 1307 masked_insert.Run(); | 1317 masked_insert.Run(); |
| 1308 masked_insert.Reset(true); | 1318 masked_insert.Reset(true); |
| 1309 | 1319 |
| 1310 // Save the use count and use date of the card. | 1320 // Save the use count and use date of the card. |
| 1311 UpdateServerCardUsageStats(card); | 1321 UpdateServerCardMetadata(card); |
| 1312 } | 1322 } |
| 1313 | 1323 |
| 1314 // Delete all items in the unmasked table that aren't in the new set. | 1324 // Delete all items in the unmasked table that aren't in the new set. |
| 1315 sql::Statement unmasked_delete(db_->GetUniqueStatement( | 1325 sql::Statement unmasked_delete(db_->GetUniqueStatement( |
| 1316 "DELETE FROM unmasked_credit_cards WHERE id NOT IN " | 1326 "DELETE FROM unmasked_credit_cards WHERE id NOT IN " |
| 1317 "(SELECT id FROM masked_credit_cards)")); | 1327 "(SELECT id FROM masked_credit_cards)")); |
| 1318 unmasked_delete.Run(); | 1328 unmasked_delete.Run(); |
| 1319 // Do the same for metadata. | 1329 // Do the same for metadata. |
| 1320 sql::Statement metadata_delete(db_->GetUniqueStatement( | 1330 sql::Statement metadata_delete(db_->GetUniqueStatement( |
| 1321 "DELETE FROM server_card_metadata WHERE id NOT IN " | 1331 "DELETE FROM server_card_metadata WHERE id NOT IN " |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1342 s.BindBlob(1, encrypted_data.data(), | 1352 s.BindBlob(1, encrypted_data.data(), |
| 1343 static_cast<int>(encrypted_data.length())); | 1353 static_cast<int>(encrypted_data.length())); |
| 1344 s.BindInt64(2, Time::Now().ToInternalValue()); // unmask_date | 1354 s.BindInt64(2, Time::Now().ToInternalValue()); // unmask_date |
| 1345 | 1355 |
| 1346 s.Run(); | 1356 s.Run(); |
| 1347 | 1357 |
| 1348 CreditCard unmasked = masked; | 1358 CreditCard unmasked = masked; |
| 1349 unmasked.set_record_type(CreditCard::FULL_SERVER_CARD); | 1359 unmasked.set_record_type(CreditCard::FULL_SERVER_CARD); |
| 1350 unmasked.SetNumber(full_number); | 1360 unmasked.SetNumber(full_number); |
| 1351 unmasked.RecordAndLogUse(); | 1361 unmasked.RecordAndLogUse(); |
| 1352 UpdateServerCardUsageStats(unmasked); | 1362 UpdateServerCardMetadata(unmasked); |
| 1353 | 1363 |
| 1354 return db_->GetLastChangeCount() > 0; | 1364 return db_->GetLastChangeCount() > 0; |
| 1355 } | 1365 } |
| 1356 | 1366 |
| 1357 bool AutofillTable::MaskServerCreditCard(const std::string& id) { | 1367 bool AutofillTable::MaskServerCreditCard(const std::string& id) { |
| 1358 sql::Statement s(db_->GetUniqueStatement( | 1368 sql::Statement s(db_->GetUniqueStatement( |
| 1359 "DELETE FROM unmasked_credit_cards WHERE id = ?")); | 1369 "DELETE FROM unmasked_credit_cards WHERE id = ?")); |
| 1360 s.BindString(0, id); | 1370 s.BindString(0, id); |
| 1361 s.Run(); | 1371 s.Run(); |
| 1362 return db_->GetLastChangeCount() > 0; | 1372 return db_->GetLastChangeCount() > 0; |
| 1363 } | 1373 } |
| 1364 | 1374 |
| 1365 bool AutofillTable::UpdateServerCardUsageStats( | 1375 bool AutofillTable::UpdateServerCardMetadata(const CreditCard& credit_card) { |
| 1366 const CreditCard& credit_card) { | |
| 1367 DCHECK_NE(CreditCard::LOCAL_CARD, credit_card.record_type()); | 1376 DCHECK_NE(CreditCard::LOCAL_CARD, credit_card.record_type()); |
| 1368 sql::Transaction transaction(db_); | 1377 sql::Transaction transaction(db_); |
| 1369 if (!transaction.Begin()) | 1378 if (!transaction.Begin()) |
| 1370 return false; | 1379 return false; |
| 1371 | 1380 |
| 1372 sql::Statement remove(db_->GetUniqueStatement( | 1381 sql::Statement remove(db_->GetUniqueStatement( |
| 1373 "DELETE FROM server_card_metadata WHERE id = ?")); | 1382 "DELETE FROM server_card_metadata WHERE id = ?")); |
| 1374 remove.BindString(0, credit_card.server_id()); | 1383 remove.BindString(0, credit_card.server_id()); |
| 1375 remove.Run(); | 1384 remove.Run(); |
| 1376 | 1385 |
| 1377 sql::Statement s(db_->GetUniqueStatement( | 1386 sql::Statement s( |
| 1378 "INSERT INTO server_card_metadata(use_count, use_date, id)" | 1387 db_->GetUniqueStatement("INSERT INTO server_card_metadata(use_count, " |
| 1379 "VALUES (?,?,?)")); | 1388 "use_date, billing_address_id, id)" |
|
please use gerrit instead
2017/01/11 19:23:03
You appear to have moved the billing_address_id co
sebsg
2017/01/12 15:36:31
I think it makes more sense to have it be in the s
| |
| 1389 "VALUES (?,?,?,?)")); | |
| 1380 s.BindInt64(0, credit_card.use_count()); | 1390 s.BindInt64(0, credit_card.use_count()); |
| 1381 s.BindInt64(1, credit_card.use_date().ToInternalValue()); | 1391 s.BindInt64(1, credit_card.use_date().ToInternalValue()); |
| 1382 s.BindString(2, credit_card.server_id()); | 1392 s.BindString(2, credit_card.billing_address_id()); |
| 1393 s.BindString(3, credit_card.server_id()); | |
| 1383 s.Run(); | 1394 s.Run(); |
| 1384 | 1395 |
| 1385 transaction.Commit(); | 1396 transaction.Commit(); |
| 1386 | 1397 |
| 1387 return db_->GetLastChangeCount() > 0; | 1398 return db_->GetLastChangeCount() > 0; |
| 1388 } | 1399 } |
| 1389 | 1400 |
| 1390 bool AutofillTable::UpdateServerAddressUsageStats( | 1401 // TODO(crbug.com/680182): Record the address conversion status. |
|
please use gerrit instead
2017/01/11 19:23:03
This comment is not clear. Please explain what you
sebsg
2017/01/12 15:36:31
Tried to make the comment more clear. It's just to
| |
| 1402 bool AutofillTable::UpdateServerAddressMetadata( | |
| 1391 const AutofillProfile& profile) { | 1403 const AutofillProfile& profile) { |
| 1392 DCHECK_EQ(AutofillProfile::SERVER_PROFILE, profile.record_type()); | 1404 DCHECK_EQ(AutofillProfile::SERVER_PROFILE, profile.record_type()); |
| 1393 | 1405 |
| 1394 sql::Transaction transaction(db_); | 1406 sql::Transaction transaction(db_); |
| 1395 if (!transaction.Begin()) | 1407 if (!transaction.Begin()) |
| 1396 return false; | 1408 return false; |
| 1397 | 1409 |
| 1398 sql::Statement remove(db_->GetUniqueStatement( | 1410 sql::Statement remove(db_->GetUniqueStatement( |
| 1399 "DELETE FROM server_address_metadata WHERE id = ?")); | 1411 "DELETE FROM server_address_metadata WHERE id = ?")); |
| 1400 remove.BindString(0, profile.server_id()); | 1412 remove.BindString(0, profile.server_id()); |
| 1401 remove.Run(); | 1413 remove.Run(); |
| 1402 | 1414 |
| 1403 sql::Statement s(db_->GetUniqueStatement( | 1415 sql::Statement s( |
| 1404 "INSERT INTO server_address_metadata(use_count, use_date, id)" | 1416 db_->GetUniqueStatement("INSERT INTO server_address_metadata(use_count, " |
| 1405 "VALUES (?,?,?)")); | 1417 "use_date, has_converted, id)" |
| 1418 "VALUES (?,?,?,?)")); | |
| 1406 s.BindInt64(0, profile.use_count()); | 1419 s.BindInt64(0, profile.use_count()); |
| 1407 s.BindInt64(1, profile.use_date().ToInternalValue()); | 1420 s.BindInt64(1, profile.use_date().ToInternalValue()); |
| 1408 s.BindString(2, profile.server_id()); | 1421 s.BindBool(2, false); |
| 1422 s.BindString(3, profile.server_id()); | |
| 1409 s.Run(); | 1423 s.Run(); |
| 1410 | 1424 |
| 1411 transaction.Commit(); | 1425 transaction.Commit(); |
| 1412 | 1426 |
| 1413 return db_->GetLastChangeCount() > 0; | 1427 return db_->GetLastChangeCount() > 0; |
| 1414 } | 1428 } |
| 1415 | 1429 |
| 1416 bool AutofillTable::UpdateServerCardBillingAddress( | |
| 1417 const CreditCard& credit_card) { | |
| 1418 DCHECK_NE(CreditCard::LOCAL_CARD, credit_card.record_type()); | |
| 1419 | |
| 1420 sql::Statement update(db_->GetUniqueStatement( | |
| 1421 "UPDATE masked_credit_cards SET billing_address_id = ? " | |
| 1422 "WHERE id = ?")); | |
| 1423 update.BindString(0, credit_card.billing_address_id()); | |
| 1424 update.BindString(1, credit_card.server_id()); | |
| 1425 if (!update.Run()) | |
| 1426 return false; | |
| 1427 | |
| 1428 return db_->GetLastChangeCount() > 0; | |
| 1429 } | |
| 1430 | |
| 1431 bool AutofillTable::ClearAllServerData() { | 1430 bool AutofillTable::ClearAllServerData() { |
| 1432 sql::Transaction transaction(db_); | 1431 sql::Transaction transaction(db_); |
| 1433 if (!transaction.Begin()) | 1432 if (!transaction.Begin()) |
| 1434 return false; // Some error, nothing was changed. | 1433 return false; // Some error, nothing was changed. |
| 1435 | 1434 |
| 1436 sql::Statement masked(db_->GetUniqueStatement( | 1435 sql::Statement masked(db_->GetUniqueStatement( |
| 1437 "DELETE FROM masked_credit_cards")); | 1436 "DELETE FROM masked_credit_cards")); |
| 1438 masked.Run(); | 1437 masked.Run(); |
| 1439 bool changed = db_->GetLastChangeCount() > 0; | 1438 bool changed = db_->GetLastChangeCount() > 0; |
| 1440 | 1439 |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1950 } | 1949 } |
| 1951 } | 1950 } |
| 1952 return true; | 1951 return true; |
| 1953 } | 1952 } |
| 1954 | 1953 |
| 1955 bool AutofillTable::InitServerCardMetadataTable() { | 1954 bool AutofillTable::InitServerCardMetadataTable() { |
| 1956 if (!db_->DoesTableExist("server_card_metadata")) { | 1955 if (!db_->DoesTableExist("server_card_metadata")) { |
| 1957 if (!db_->Execute("CREATE TABLE server_card_metadata (" | 1956 if (!db_->Execute("CREATE TABLE server_card_metadata (" |
| 1958 "id VARCHAR NOT NULL," | 1957 "id VARCHAR NOT NULL," |
| 1959 "use_count INTEGER NOT NULL DEFAULT 0, " | 1958 "use_count INTEGER NOT NULL DEFAULT 0, " |
| 1960 "use_date INTEGER NOT NULL DEFAULT 0)")) { | 1959 "use_date INTEGER NOT NULL DEFAULT 0, " |
| 1960 "billing_address_id VARCHAR)")) { | |
| 1961 NOTREACHED(); | 1961 NOTREACHED(); |
| 1962 return false; | 1962 return false; |
| 1963 } | 1963 } |
| 1964 } | 1964 } |
| 1965 return true; | 1965 return true; |
| 1966 } | 1966 } |
| 1967 | 1967 |
| 1968 bool AutofillTable::InitServerAddressesTable() { | 1968 bool AutofillTable::InitServerAddressesTable() { |
| 1969 if (!db_->DoesTableExist("server_addresses")) { | 1969 if (!db_->DoesTableExist("server_addresses")) { |
| 1970 // The space after language_code is necessary to match what sqlite does | 1970 // The space after language_code is necessary to match what sqlite does |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1988 } | 1988 } |
| 1989 } | 1989 } |
| 1990 return true; | 1990 return true; |
| 1991 } | 1991 } |
| 1992 | 1992 |
| 1993 bool AutofillTable::InitServerAddressMetadataTable() { | 1993 bool AutofillTable::InitServerAddressMetadataTable() { |
| 1994 if (!db_->DoesTableExist("server_address_metadata")) { | 1994 if (!db_->DoesTableExist("server_address_metadata")) { |
| 1995 if (!db_->Execute("CREATE TABLE server_address_metadata (" | 1995 if (!db_->Execute("CREATE TABLE server_address_metadata (" |
| 1996 "id VARCHAR NOT NULL," | 1996 "id VARCHAR NOT NULL," |
| 1997 "use_count INTEGER NOT NULL DEFAULT 0, " | 1997 "use_count INTEGER NOT NULL DEFAULT 0, " |
| 1998 "use_date INTEGER NOT NULL DEFAULT 0)")) { | 1998 "use_date INTEGER NOT NULL DEFAULT 0, " |
| 1999 "has_converted BOOL NOT NULL DEFAULT FALSE)")) { | |
| 1999 NOTREACHED(); | 2000 NOTREACHED(); |
| 2000 return false; | 2001 return false; |
| 2001 } | 2002 } |
| 2002 } | 2003 } |
| 2003 return true; | 2004 return true; |
| 2004 } | 2005 } |
| 2005 | 2006 |
| 2006 bool AutofillTable::InitAutofillSyncMetadataTable() { | 2007 bool AutofillTable::InitAutofillSyncMetadataTable() { |
| 2007 if (!db_->DoesTableExist("autofill_sync_metadata")) { | 2008 if (!db_->DoesTableExist("autofill_sync_metadata")) { |
| 2008 if (!db_->Execute("CREATE TABLE autofill_sync_metadata (" | 2009 if (!db_->Execute("CREATE TABLE autofill_sync_metadata (" |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2466 if (!db_->Execute("CREATE TABLE autofill_sync_metadata (" | 2467 if (!db_->Execute("CREATE TABLE autofill_sync_metadata (" |
| 2467 "storage_key VARCHAR PRIMARY KEY NOT NULL," | 2468 "storage_key VARCHAR PRIMARY KEY NOT NULL," |
| 2468 "value BLOB)")) { | 2469 "value BLOB)")) { |
| 2469 return false; | 2470 return false; |
| 2470 } | 2471 } |
| 2471 return db_->Execute( | 2472 return db_->Execute( |
| 2472 "CREATE TABLE autofill_model_type_state (id INTEGER PRIMARY KEY, value " | 2473 "CREATE TABLE autofill_model_type_state (id INTEGER PRIMARY KEY, value " |
| 2473 "BLOB)"); | 2474 "BLOB)"); |
| 2474 } | 2475 } |
| 2475 | 2476 |
| 2477 bool AutofillTable::MigrateToVersion71AddServerCardMetadataBillingAddress() { | |
| 2478 sql::Transaction transaction(db_); | |
| 2479 if (!transaction.Begin()) | |
| 2480 return false; | |
| 2481 | |
| 2482 if (!db_->DoesColumnExist("server_card_metadata", "billing_address_id") && | |
| 2483 !db_->Execute("ALTER TABLE server_card_metadata ADD COLUMN " | |
| 2484 "billing_address_id VARCHAR")) { | |
| 2485 return false; | |
| 2486 } | |
| 2487 | |
| 2488 if (!db_->DoesColumnExist("server_address_metadata", "has_converted") && | |
| 2489 !db_->Execute("ALTER TABLE server_address_metadata ADD COLUMN " | |
| 2490 "has_converted BOOL NOT NULL DEFAULT FALSE")) { | |
| 2491 return false; | |
| 2492 } | |
| 2493 | |
| 2494 return transaction.Commit(); | |
| 2495 } | |
| 2496 | |
| 2476 } // namespace autofill | 2497 } // namespace autofill |
| OLD | NEW |