diff options
author | stanisc <stanisc@chromium.org> | 2015-12-09 15:42:49 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-09 23:43:51 +0000 |
commit | 0a82539710a4a39623690525c94fb3bd12e8f4fa (patch) | |
tree | 00a819b5780aa3024ea60c23461e6cec358c37d7 | |
parent | e0a7a7c95cb93a04d1374d9852bc1fa8781cd484 (diff) | |
download | chromium_src-0a82539710a4a39623690525c94fb3bd12e8f4fa.zip chromium_src-0a82539710a4a39623690525c94fb3bd12e8f4fa.tar.gz chromium_src-0a82539710a4a39623690525c94fb3bd12e8f4fa.tar.bz2 |
Sync: Remove several unused columns from Sync DB meta_info table
BUG=118356,124140
Review URL: https://codereview.chromium.org/1509673005
Cr-Commit-Position: refs/heads/master@{#364218}
-rw-r--r-- | sync/syncable/directory_backing_store.cc | 163 | ||||
-rw-r--r-- | sync/syncable/directory_backing_store.h | 4 | ||||
-rw-r--r-- | sync/syncable/directory_backing_store_unittest.cc | 157 | ||||
-rw-r--r-- | sync/test/test_directory_backing_store.h | 1 |
4 files changed, 234 insertions, 91 deletions
diff --git a/sync/syncable/directory_backing_store.cc b/sync/syncable/directory_backing_store.cc index cbe943b..e57f246 100644 --- a/sync/syncable/directory_backing_store.cc +++ b/sync/syncable/directory_backing_store.cc @@ -34,7 +34,7 @@ namespace syncer { namespace syncable { // Increment this version whenever updating DB tables. -const int32 kCurrentDBVersion = 89; +const int32 kCurrentDBVersion = 90; // Iterate over the fields of |entry| and bind each to |statement| for // updating. Returns the number of args bound. @@ -257,7 +257,8 @@ void UploadModelTypeEntryCount(const int total_specifics_copies, DirectoryBackingStore::DirectoryBackingStore(const string& dir_name) : dir_name_(dir_name), database_page_size_(32768), - needs_column_refresh_(false) { + needs_metas_column_refresh_(false), + needs_share_info_column_refresh_(false) { DCHECK(base::ThreadTaskRunnerHandle::IsSet()); ResetAndCreateConnection(); } @@ -267,7 +268,8 @@ DirectoryBackingStore::DirectoryBackingStore(const string& dir_name, : dir_name_(dir_name), database_page_size_(32768), db_(db), - needs_column_refresh_(false) { + needs_metas_column_refresh_(false), + needs_share_info_column_refresh_(false) { DCHECK(base::ThreadTaskRunnerHandle::IsSet()); } @@ -552,10 +554,16 @@ bool DirectoryBackingStore::InitializeTables() { version_on_disk = 89; } + // Version 90 migration removes several columns from share_info table. + if (version_on_disk == 89) { + if (MigrateVersion89To90()) + version_on_disk = 90; + } + // If one of the migrations requested it, drop columns that aren't current. // It's only safe to do this after migrating all the way to the current // version. - if (version_on_disk == kCurrentDBVersion && needs_column_refresh_) { + if (version_on_disk == kCurrentDBVersion && needs_column_refresh()) { if (!RefreshColumns()) version_on_disk = 0; } @@ -573,15 +581,6 @@ bool DirectoryBackingStore::InitializeTables() { return false; } - sql::Statement s(db_->GetUniqueStatement( - "SELECT db_create_version, db_create_time FROM share_info")); - if (!s.Step()) - return false; - string db_create_version = s.ColumnString(0); - int db_create_time = s.ColumnInt(1); - DVLOG(1) << "DB created at " << db_create_time << " by version " << - db_create_version; - return transaction.Commit(); } @@ -589,55 +588,58 @@ bool DirectoryBackingStore::InitializeTables() { // the currently used columns then copying all rows from the old tables into // this new one. The tables are then rearranged so the new replaces the old. bool DirectoryBackingStore::RefreshColumns() { - DCHECK(needs_column_refresh_); + DCHECK(needs_metas_column_refresh_ || needs_share_info_column_refresh_); - // Create a new table named temp_metas. - SafeDropTable("temp_metas"); - if (!CreateMetasTable(true)) - return false; + if (needs_metas_column_refresh_) { + // Create a new table named temp_metas. + SafeDropTable("temp_metas"); + if (!CreateMetasTable(true)) + return false; - // Populate temp_metas from metas. - // - // At this point, the metas table may contain columns belonging to obsolete - // schema versions. This statement explicitly lists only the columns that - // belong to the current schema version, so the obsolete columns will be - // effectively dropped once we rename temp_metas over top of metas. - std::string query = "INSERT INTO temp_metas ("; - AppendColumnList(&query); - query.append(") SELECT "); - AppendColumnList(&query); - query.append(" FROM metas"); - if (!db_->Execute(query.c_str())) - return false; + // Populate temp_metas from metas. + // + // At this point, the metas table may contain columns belonging to obsolete + // schema versions. This statement explicitly lists only the columns that + // belong to the current schema version, so the obsolete columns will be + // effectively dropped once we rename temp_metas over top of metas. + std::string query = "INSERT INTO temp_metas ("; + AppendColumnList(&query); + query.append(") SELECT "); + AppendColumnList(&query); + query.append(" FROM metas"); + if (!db_->Execute(query.c_str())) + return false; - // Drop metas. - SafeDropTable("metas"); + // Drop metas. + SafeDropTable("metas"); - // Rename temp_metas -> metas. - if (!db_->Execute("ALTER TABLE temp_metas RENAME TO metas")) - return false; + // Rename temp_metas -> metas. + if (!db_->Execute("ALTER TABLE temp_metas RENAME TO metas")) + return false; - // Repeat the process for share_info. - SafeDropTable("temp_share_info"); - if (!CreateShareInfoTable(true)) - return false; + needs_metas_column_refresh_ = false; + } - // TODO(rlarocque, 124140): Remove notification_state. - if (!db_->Execute( - "INSERT INTO temp_share_info (id, name, store_birthday, " - "db_create_version, db_create_time, next_id, cache_guid," - "notification_state, bag_of_chips) " - "SELECT id, name, store_birthday, db_create_version, " - "db_create_time, next_id, cache_guid, notification_state, " - "bag_of_chips " - "FROM share_info")) - return false; + if (needs_share_info_column_refresh_) { + // Repeat the process for share_info. + SafeDropTable("temp_share_info"); + if (!CreateShareInfoTable(true)) + return false; - SafeDropTable("share_info"); - if (!db_->Execute("ALTER TABLE temp_share_info RENAME TO share_info")) - return false; + if (!db_->Execute( + "INSERT INTO temp_share_info (id, name, store_birthday, " + "cache_guid, bag_of_chips) " + "SELECT id, name, store_birthday, cache_guid, bag_of_chips " + "FROM share_info")) + return false; + + SafeDropTable("share_info"); + if (!db_->Execute("ALTER TABLE temp_share_info RENAME TO share_info")) + return false; + + needs_share_info_column_refresh_ = false; + } - needs_column_refresh_ = false; return true; } @@ -776,7 +778,8 @@ void DirectoryBackingStore::DropAllTables() { SafeDropTable("extended_attributes"); SafeDropTable("models"); SafeDropTable("temp_models"); - needs_column_refresh_ = false; + needs_metas_column_refresh_ = false; + needs_share_info_column_refresh_ = false; } // static @@ -864,7 +867,7 @@ bool DirectoryBackingStore::MigrateVersion67To68() { // string SERVER_NAME // No data migration is necessary, but we should do a column refresh. SetVersion(68); - needs_column_refresh_ = true; + needs_metas_column_refresh_ = true; return true; } @@ -877,7 +880,7 @@ bool DirectoryBackingStore::MigrateVersion69To70() { if (!db_->Execute( "ALTER TABLE metas ADD COLUMN unique_client_tag varchar")) return false; - needs_column_refresh_ = true; + needs_metas_column_refresh_ = true; if (!db_->Execute( "UPDATE metas SET unique_server_tag = singleton_tag")) @@ -958,7 +961,7 @@ bool DirectoryBackingStore::MigrateVersion68To69() { return false; SetVersion(69); - needs_column_refresh_ = true; // Trigger deletion of old columns. + needs_metas_column_refresh_ = true; // Trigger deletion of old columns. return true; } @@ -1138,7 +1141,7 @@ bool DirectoryBackingStore::MigrateVersion75To76() { // autofill_profiles_added_during_migration // No data migration is necessary, but we should do a column refresh. SetVersion(76); - needs_column_refresh_ = true; + needs_share_info_column_refresh_ = true; return true; } @@ -1232,7 +1235,7 @@ bool DirectoryBackingStore::MigrateVersion80To81() { } SetVersion(81); - needs_column_refresh_ = true; + needs_metas_column_refresh_ = true; return true; } @@ -1410,7 +1413,7 @@ bool DirectoryBackingStore::MigrateVersion85To86() { } SetVersion(86); - needs_column_refresh_ = true; + needs_metas_column_refresh_ = true; return true; } @@ -1422,7 +1425,7 @@ bool DirectoryBackingStore::MigrateVersion86To87() { return false; } SetVersion(87); - needs_column_refresh_ = true; + needs_metas_column_refresh_ = true; return true; } @@ -1443,7 +1446,19 @@ bool DirectoryBackingStore::MigrateVersion88To89() { return false; } SetVersion(89); - needs_column_refresh_ = true; + needs_metas_column_refresh_ = true; + return true; +} + +bool DirectoryBackingStore::MigrateVersion89To90() { + // This change removed 4 columns from meta_info: + // db_create_version + // db_create_time + // next_id + // notification_state + // No data migration is necessary, but we should do a column refresh. + SetVersion(90); + needs_share_info_column_refresh_ = true; return true; } @@ -1477,24 +1492,13 @@ bool DirectoryBackingStore::CreateTables() { "(?, " // id "?, " // name "?, " // store_birthday - "?, " // db_create_version - "?, " // db_create_time - "-2, " // next_id "?, " // cache_guid - // TODO(rlarocque, 124140): Remove notification_state field. - "?, " // notification_state "?);")); // bag_of_chips s.BindString(0, dir_name_); // id s.BindString(1, dir_name_); // name s.BindString(2, std::string()); // store_birthday - // TODO(akalin): Remove this unused db_create_version field. (Or - // actually use it for something.) http://crbug.com/118356 - s.BindString(3, "Unknown"); // db_create_version - s.BindInt(4, static_cast<int32>(time(0))); // db_create_time - s.BindString(5, GenerateCacheGUID()); // cache_guid - // TODO(rlarocque, 124140): Remove this unused notification-state field. - s.BindBlob(6, NULL, 0); // notification_state - s.BindBlob(7, NULL, 0); // bag_of_chips + s.BindString(3, GenerateCacheGUID()); // cache_guid + s.BindBlob(4, NULL, 0); // bag_of_chips if (!s.Run()) return false; } @@ -1600,12 +1604,7 @@ bool DirectoryBackingStore::CreateShareInfoTable(bool is_temporary) { "id TEXT primary key, " "name TEXT, " "store_birthday TEXT, " - "db_create_version TEXT, " - "db_create_time INT, " - "next_id INT default -2, " "cache_guid TEXT, " - // TODO(rlarocque, 124140): Remove notification_state field. - "notification_state BLOB, " "bag_of_chips BLOB" ")"); return db_->Execute(query.c_str()); @@ -1721,7 +1720,7 @@ bool DirectoryBackingStore::Vacuum() { } bool DirectoryBackingStore::needs_column_refresh() const { - return needs_column_refresh_; + return needs_metas_column_refresh_ || needs_share_info_column_refresh_; } void DirectoryBackingStore::ResetAndCreateConnection() { diff --git a/sync/syncable/directory_backing_store.h b/sync/syncable/directory_backing_store.h index 422d13d..e3c8598 100644 --- a/sync/syncable/directory_backing_store.h +++ b/sync/syncable/directory_backing_store.h @@ -173,6 +173,7 @@ class SYNC_EXPORT_PRIVATE DirectoryBackingStore : public base::NonThreadSafe { bool MigrateVersion86To87(); bool MigrateVersion87To88(); bool MigrateVersion88To89(); + bool MigrateVersion89To90(); // Accessor for needs_column_refresh_. Used in tests. bool needs_column_refresh() const; @@ -249,7 +250,8 @@ class SYNC_EXPORT_PRIVATE DirectoryBackingStore : public base::NonThreadSafe { // Set to true if migration left some old columns around that need to be // discarded. - bool needs_column_refresh_; + bool needs_metas_column_refresh_; + bool needs_share_info_column_refresh_; // We keep a copy of the Closure so we reinstall it when the underlying // sql::Connection is destroyed/recreated. diff --git a/sync/syncable/directory_backing_store_unittest.cc b/sync/syncable/directory_backing_store_unittest.cc index 24a2014..56e91b0 100644 --- a/sync/syncable/directory_backing_store_unittest.cc +++ b/sync/syncable/directory_backing_store_unittest.cc @@ -100,9 +100,10 @@ class MigrationTest : public testing::TestWithParam<int> { void SetUpVersion87Database(sql::Connection* connection); void SetUpVersion88Database(sql::Connection* connection); void SetUpVersion89Database(sql::Connection* connection); + void SetUpVersion90Database(sql::Connection* connection); void SetUpCurrentDatabaseAndCheckVersion(sql::Connection* connection) { - SetUpVersion89Database(connection); // Prepopulates data. + SetUpVersion90Database(connection); // Prepopulates data. scoped_ptr<TestDirectoryBackingStore> dbs( new TestDirectoryBackingStore(GetUsername(), connection)); ASSERT_EQ(kCurrentDBVersion, dbs->GetVersion()); @@ -2791,7 +2792,6 @@ void MigrationTest::SetUpVersion88Database(sql::Connection* connection) { ASSERT_TRUE(connection->CommitTransaction()); } - void MigrationTest::SetUpVersion89Database(sql::Connection* connection) { ASSERT_TRUE(connection->is_open()); ASSERT_TRUE(connection->BeginTransaction()); @@ -2905,6 +2905,117 @@ void MigrationTest::SetUpVersion89Database(sql::Connection* connection) { ASSERT_TRUE(connection->CommitTransaction()); } +void MigrationTest::SetUpVersion90Database(sql::Connection* connection) { + ASSERT_TRUE(connection->is_open()); + ASSERT_TRUE(connection->BeginTransaction()); + ASSERT_TRUE(connection->Execute( + "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);" + "INSERT INTO 'share_version' VALUES('nick@chromium.org',90);" + "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, tr" + "ansaction_version BIGINT default 0, context BLOB);" + "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1,NULL);" + "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base" + "_version bigint default -1,server_version bigint default 0,local_exte" + "rnal_id bigint default 0,transaction_version bigint default 0,mtime b" + "igint default 0,server_mtime bigint default 0,ctime bigint default 0," + "server_ctime bigint default 0,id varchar(255) default 'r',parent_id v" + "archar(255) default 'r',server_parent_id varchar(255) default 'r',is_" + "unsynced bit default 0,is_unapplied_update bit default 0,is_del bit d" + "efault 0,is_dir bit default 0,server_is_dir bit default 0,server_is_d" + "el bit default 0,non_unique_name varchar,server_non_unique_name varch" + "ar(255),unique_server_tag varchar,unique_client_tag varchar,unique_bo" + "okmark_tag varchar,specifics blob,server_specifics blob,base_server_s" + "pecifics blob,server_unique_position blob,unique_position blob,attach" + "ment_metadata blob,server_attachment_metadata blob);" + "INSERT INTO 'metas' VALUES(1,-1,0,0,0," + META_PROTO_TIMES_VALS(1) + ",'r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',X'',NULL,X'2200'" + ",X'2200',NULL,NULL);" + "INSERT INTO 'metas' VALUES(6,694,694,6,0," + META_PROTO_TIMES_VALS(6) + ",'s_ID_6','s_ID_9','s_ID_9',0,0,0,1,1,0,'The Internet','The Internet'" + ",NULL,NULL,X'6754307476346749735A5734654D653273625336557753582F77673D" + "',X'C2881000',X'C2881000',NULL,X'22247FFFFFFFFFC000006754307476346749" + "735A5734654D653273625336557753582F77673D',X'22247FFFFFFFFFC0000067543" + "07476346749735A5734654D653273625336557753582F77673D',NULL,NULL);" + "INSERT INTO 'metas' VALUES(7,663,663,0,0," + META_PROTO_TIMES_VALS(7) + ",'s_ID_7','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google" + "_chrome',NULL,X'',NULL,NULL,NULL,X'2200',X'2200',NULL,NULL);" + "INSERT INTO 'metas' VALUES(8,664,664,0,0," + META_PROTO_TIMES_VALS(8) + ",'s_ID_8','s_ID_7','s_ID_7',0,0,0,1,1,0,'Bookmarks','Bookmarks','goog" + "le_chrome_bookmarks',NULL,X'',X'C2881000',X'C2881000',NULL,X'2200',X'" + "2200',NULL,NULL);" + "INSERT INTO 'metas' VALUES(9,665,665,1,0," + META_PROTO_TIMES_VALS(9) + ",'s_ID_9','s_ID_8','s_ID_8',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar'" + ",'bookmark_bar',NULL,X'',X'C2881000',X'C2881000',NULL,X'2200',X'2200'" + ",NULL,NULL);" + "INSERT INTO 'metas' VALUES(10,666,666,2,0," + META_PROTO_TIMES_VALS(10) + ",'s_ID_10','s_ID_8','s_ID_8',0,0,0,1,1,0,'Other Bookmarks','Other Boo" + "kmarks','other_bookmarks',NULL,X'',X'C2881000',X'C2881000',NULL,X'220" + "0',X'2200',NULL,NULL);" + "INSERT INTO 'metas' VALUES(11,683,683,8,0," + META_PROTO_TIMES_VALS(11) + ",'s_ID_11','s_ID_6','s_ID_6',0,0,0,0,0,0,'Home (The Chromium Projects" + ")','Home (The Chromium Projects)',NULL,NULL,X'50514C784A456D623579366" + "267644237646A7A2B62314130346E493D',X'C28810220A18687474703A2F2F646576" + "2E6368726F6D69756D2E6F72672F1206414741545741',X'C28810290A1D687474703" + "A2F2F6465762E6368726F6D69756D2E6F72672F6F7468657212084146414756415346" + "',NULL,X'22247FFFFFFFFFF0000050514C784A456D623579366267644237646A7A2B" + "62314130346E493D',X'22247FFFFFFFFFF0000050514C784A456D623579366267644" + "237646A7A2B62314130346E493D',NULL,NULL);" + "INSERT INTO 'metas' VALUES(12,685,685,9,0," + META_PROTO_TIMES_VALS(12) + ",'s_ID_12','s_ID_6','s_ID_6',0,0,0,1,1,0,'Extra Bookmarks','Extra Boo" + "kmarks',NULL,NULL,X'7867626A704A646134635A6F616C376A49513338734B46324" + "837773D',X'C2881000',X'C2881000',NULL,X'222480000000000000007867626A7" + "04A646134635A6F616C376A49513338734B46324837773D',X'222480000000000000" + "007867626A704A646134635A6F616C376A49513338734B46324837773D',NULL,NULL" + ");" + "INSERT INTO 'metas' VALUES(13,687,687,10,0," + META_PROTO_TIMES_VALS(13) + ",'s_ID_13','s_ID_6','s_ID_6',0,0,0,0,0,0,'ICANN | Internet Corporatio" + "n for Assigned Names and Numbers','ICANN | Internet Corporation for A" + "ssigned Names and Numbers',NULL,NULL,X'3142756B572F774176695650417967" + "2B304A614A514B3452384A413D',X'C28810240A15687474703A2F2F7777772E69636" + "16E6E2E636F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F" + "2F7777772E6963616E6E2E636F6D2F120744414146415346',NULL,X'22247FFFFFFF" + "FFF200003142756B572F7741766956504179672B304A614A514B3452384A413D',X'2" + "2247FFFFFFFFFF200003142756B572F7741766956504179672B304A614A514B345238" + "4A413D',NULL,NULL);" + "INSERT INTO 'metas' VALUES(14,692,692,11,0," + META_PROTO_TIMES_VALS(14) + ",'s_ID_14','s_ID_6','s_ID_6',0,0,0,0,0,0,'The WebKit Open Source Proj" + "ect','The WebKit Open Source Project',NULL,NULL,X'5A5678314E797636457" + "9524D3177494F7236563159552F6E644C553D',X'C288101A0A12687474703A2F2F77" + "65626B69742E6F72672F1204504E4758',X'C288101C0A13687474703A2F2F7765626" + "B69742E6F72672F781205504E473259',NULL,X'222480000000001000005A5678314" + "E7976364579524D3177494F7236563159552F6E644C553D',X'222480000000001000" + "005A5678314E7976364579524D3177494F7236563159552F6E644C553D',NULL,NULL" + ");" + "CREATE TABLE deleted_metas (metahandle bigint primary key ON CONFLICT FA" + "IL,base_version bigint default -1,server_version bigint default 0,loc" + "al_external_id bigint default 0,transaction_version bigint default 0," + "mtime bigint default 0,server_mtime bigint default 0,ctime bigint def" + "ault 0,server_ctime bigint default 0,id varchar(255) default 'r',pare" + "nt_id varchar(255) default 'r',server_parent_id varchar(255) default " + "'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is_de" + "l bit default 0,is_dir bit default 0,server_is_dir bit default 0,serv" + "er_is_del bit default 0,non_unique_name varchar,server_non_unique_nam" + "e varchar(255),unique_server_tag varchar,unique_client_tag varchar,un" + "ique_bookmark_tag varchar,specifics blob,server_specifics blob,base_s" + "erver_specifics blob,server_unique_position blob,unique_position blob" + ",attachment_metadata blob,server_attachment_metadata blob);" + "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda" + "y TEXT, cache_guid TEXT, bag_of_chips BLOB);" + "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'," + "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','9010788312004066376x-66092343" + "93368420856x',NULL);")); + ASSERT_TRUE(connection->CommitTransaction()); +} TEST_F(DirectoryBackingStoreTest, MigrateVersion67To68) { sql::Connection connection; @@ -3396,6 +3507,30 @@ TEST_F(DirectoryBackingStoreTest, MigrateVersion88To89) { EXPECT_TRUE(dbs->needs_column_refresh()); } +TEST_F(DirectoryBackingStoreTest, MigrateVersion89To90) { + sql::Connection connection; + ASSERT_TRUE(connection.OpenInMemory()); + SetUpVersion89Database(&connection); + ASSERT_TRUE(connection.DoesColumnExist("share_info", "db_create_version")); + ASSERT_TRUE(connection.DoesColumnExist("share_info", "db_create_time")); + ASSERT_TRUE(connection.DoesColumnExist("share_info", "next_id")); + ASSERT_TRUE(connection.DoesColumnExist("share_info", "notification_state")); + + scoped_ptr<TestDirectoryBackingStore> dbs( + new TestDirectoryBackingStore(GetUsername(), &connection)); + ASSERT_TRUE(dbs->MigrateVersion89To90()); + ASSERT_EQ(90, dbs->GetVersion()); + EXPECT_TRUE(dbs->needs_column_refresh()); + + ASSERT_TRUE(dbs->RefreshColumns()); + EXPECT_FALSE(dbs->needs_column_refresh()); + + ASSERT_FALSE(connection.DoesColumnExist("share_info", "db_create_version")); + ASSERT_FALSE(connection.DoesColumnExist("share_info", "db_create_time")); + ASSERT_FALSE(connection.DoesColumnExist("share_info", "next_id")); + ASSERT_FALSE(connection.DoesColumnExist("share_info", "notification_state")); +} + // The purpose of this test case is to make it easier to get a dump of the // database so you can implement a SetUpVersionYDatabase method. Here's what // you should do: @@ -3417,13 +3552,13 @@ TEST_F(DirectoryBackingStoreTest, MigrateToLatestAndDump) { { sql::Connection connection; ASSERT_TRUE(connection.Open(GetDatabasePath())); - SetUpVersion88Database(&connection); // Update this. + SetUpVersion89Database(&connection); // Update this. scoped_ptr<TestDirectoryBackingStore> dbs( new TestDirectoryBackingStore(GetUsername(), &connection)); - ASSERT_TRUE(dbs->MigrateVersion88To89()); // Update this. + ASSERT_TRUE(dbs->MigrateVersion89To90()); // Update this. ASSERT_TRUE(LoadAndIgnoreReturnedData(dbs.get())); - EXPECT_EQ(89, dbs->GetVersion()); // Update this. + EXPECT_EQ(90, dbs->GetVersion()); // Update this. ASSERT_FALSE(dbs->needs_column_refresh()); } // Set breakpoint here. @@ -3530,6 +3665,9 @@ TEST_P(MigrationTest, ToCurrentVersion) { case 89: SetUpVersion89Database(&connection); break; + case 90: + SetUpVersion90Database(&connection); + break; default: // If you see this error, it may mean that you've increased the // database version number but you haven't finished adding unit tests @@ -3581,9 +3719,6 @@ TEST_P(MigrationTest, ToCurrentVersion) { // Removed extended attributes in Version 72. ASSERT_FALSE(connection.DoesTableExist("extended_attributes")); - // Columns added in Version 73. - ASSERT_TRUE(connection.DoesColumnExist("share_info", "notification_state")); - // Column replaced in version 75. ASSERT_TRUE(connection.DoesColumnExist("models", "progress_marker")); ASSERT_FALSE(connection.DoesColumnExist("models", "last_download_timestamp")); @@ -3630,6 +3765,12 @@ TEST_P(MigrationTest, ToCurrentVersion) { ASSERT_TRUE( connection.DoesColumnExist("metas", "server_attachment_metadata")); + // Columns removed in version 90. + ASSERT_FALSE(connection.DoesColumnExist("share_info", "db_create_version")); + ASSERT_FALSE(connection.DoesColumnExist("share_info", "db_create_time")); + ASSERT_FALSE(connection.DoesColumnExist("share_info", "next_id")); + ASSERT_FALSE(connection.DoesColumnExist("share_info", "notification_state")); + // Check download_progress state (v75 migration) ASSERT_EQ(694, dir_info.kernel_info.download_progress[BOOKMARKS] diff --git a/sync/test/test_directory_backing_store.h b/sync/test/test_directory_backing_store.h index 1e71816..53f89e5 100644 --- a/sync/test/test_directory_backing_store.h +++ b/sync/test/test_directory_backing_store.h @@ -52,6 +52,7 @@ class TestDirectoryBackingStore : public DirectoryBackingStore { FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, MigrateVersion86To87); FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, MigrateVersion87To88); FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, MigrateVersion88To89); + FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, MigrateVersion89To90); FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, DetectInvalidPosition); FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, ModelTypeIds); FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, Corruption); |