Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / sync / syncable / directory_backing_store_unittest.cc
blobaad952340aefc2fa37452210b323e1781948c364
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "testing/gtest/include/gtest/gtest.h"
7 #include <string>
9 #include "base/file_util.h"
10 #include "base/files/file_path.h"
11 #include "base/files/scoped_temp_dir.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/stl_util.h"
14 #include "base/strings/string_number_conversions.h"
15 #include "sql/connection.h"
16 #include "sql/statement.h"
17 #include "sync/base/sync_export.h"
18 #include "sync/internal_api/public/base/node_ordinal.h"
19 #include "sync/protocol/bookmark_specifics.pb.h"
20 #include "sync/protocol/sync.pb.h"
21 #include "sync/syncable/directory_backing_store.h"
22 #include "sync/syncable/on_disk_directory_backing_store.h"
23 #include "sync/syncable/syncable-inl.h"
24 #include "sync/test/test_directory_backing_store.h"
25 #include "sync/util/time.h"
26 #include "testing/gtest/include/gtest/gtest-param-test.h"
28 namespace syncer {
29 namespace syncable {
31 SYNC_EXPORT_PRIVATE extern const int32 kCurrentDBVersion;
33 class MigrationTest : public testing::TestWithParam<int> {
34 public:
35 virtual void SetUp() {
36 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
39 protected:
40 std::string GetUsername() {
41 return "nick@chromium.org";
44 base::FilePath GetDatabasePath() {
45 return temp_dir_.path().Append(Directory::kSyncDatabaseFilename);
48 static bool LoadAndIgnoreReturnedData(DirectoryBackingStore *dbs) {
49 Directory::MetahandlesMap tmp_handles_map;
50 JournalIndex delete_journals;
51 STLValueDeleter<Directory::MetahandlesMap> deleter(&tmp_handles_map);
52 Directory::KernelLoadInfo kernel_load_info;
53 return dbs->Load(&tmp_handles_map, &delete_journals, &kernel_load_info) ==
54 OPENED;
57 void SetUpVersion67Database(sql::Connection* connection);
58 void SetUpVersion68Database(sql::Connection* connection);
59 void SetUpVersion69Database(sql::Connection* connection);
60 void SetUpVersion70Database(sql::Connection* connection);
61 void SetUpVersion71Database(sql::Connection* connection);
62 void SetUpVersion72Database(sql::Connection* connection);
63 void SetUpVersion73Database(sql::Connection* connection);
64 void SetUpVersion74Database(sql::Connection* connection);
65 void SetUpVersion75Database(sql::Connection* connection);
66 void SetUpVersion76Database(sql::Connection* connection);
67 void SetUpVersion77Database(sql::Connection* connection);
68 void SetUpVersion78Database(sql::Connection* connection);
69 void SetUpVersion79Database(sql::Connection* connection);
70 void SetUpVersion80Database(sql::Connection* connection);
71 void SetUpVersion81Database(sql::Connection* connection);
72 void SetUpVersion82Database(sql::Connection* connection);
73 void SetUpVersion83Database(sql::Connection* connection);
74 void SetUpVersion84Database(sql::Connection* connection);
75 void SetUpVersion85Database(sql::Connection* connection);
76 void SetUpVersion86Database(sql::Connection* connection);
77 void SetUpVersion87Database(sql::Connection* connection);
78 void SetUpVersion88Database(sql::Connection* connection);
79 void SetUpVersion89Database(sql::Connection* connection);
81 void SetUpCurrentDatabaseAndCheckVersion(sql::Connection* connection) {
82 SetUpVersion89Database(connection); // Prepopulates data.
83 scoped_ptr<TestDirectoryBackingStore> dbs(
84 new TestDirectoryBackingStore(GetUsername(), connection));
85 ASSERT_EQ(kCurrentDBVersion, dbs->GetVersion());
87 ASSERT_TRUE(LoadAndIgnoreReturnedData(dbs.get()));
88 ASSERT_FALSE(dbs->needs_column_refresh_);
91 private:
92 base::ScopedTempDir temp_dir_;
95 class DirectoryBackingStoreTest : public MigrationTest {};
97 #if defined(OS_WIN)
99 // On Windows, we used to store timestamps in FILETIME format.
100 #define LEGACY_META_PROTO_TIMES_1 129079956640320000LL
101 #define LEGACY_META_PROTO_TIMES_2 128976886618480000LL
102 #define LEGACY_META_PROTO_TIMES_4 129002163642690000LL
103 #define LEGACY_META_PROTO_TIMES_5 129001555500000000LL
104 #define LEGACY_META_PROTO_TIMES_6 129053976170000000LL
105 #define LEGACY_META_PROTO_TIMES_7 128976864758480000LL
106 #define LEGACY_META_PROTO_TIMES_8 128976864758480000LL
107 #define LEGACY_META_PROTO_TIMES_9 128976864758480000LL
108 #define LEGACY_META_PROTO_TIMES_10 128976864758480000LL
109 #define LEGACY_META_PROTO_TIMES_11 129079956948440000LL
110 #define LEGACY_META_PROTO_TIMES_12 129079957513650000LL
111 #define LEGACY_META_PROTO_TIMES_13 129079957985300000LL
112 #define LEGACY_META_PROTO_TIMES_14 129079958383000000LL
114 #define LEGACY_META_PROTO_TIMES_STR_1 "129079956640320000"
115 #define LEGACY_META_PROTO_TIMES_STR_2 "128976886618480000"
116 #define LEGACY_META_PROTO_TIMES_STR_4 "129002163642690000"
117 #define LEGACY_META_PROTO_TIMES_STR_5 "129001555500000000"
118 #define LEGACY_META_PROTO_TIMES_STR_6 "129053976170000000"
119 #define LEGACY_META_PROTO_TIMES_STR_7 "128976864758480000"
120 #define LEGACY_META_PROTO_TIMES_STR_8 "128976864758480000"
121 #define LEGACY_META_PROTO_TIMES_STR_9 "128976864758480000"
122 #define LEGACY_META_PROTO_TIMES_STR_10 "128976864758480000"
123 #define LEGACY_META_PROTO_TIMES_STR_11 "129079956948440000"
124 #define LEGACY_META_PROTO_TIMES_STR_12 "129079957513650000"
125 #define LEGACY_META_PROTO_TIMES_STR_13 "129079957985300000"
126 #define LEGACY_META_PROTO_TIMES_STR_14 "129079958383000000"
128 // Generated via:
130 // ruby -ane '$F[1].sub!("LEGACY_", ""); $F[2] = Integer($F[2].sub!("LL", "")) /
131 // 10000 - 11644473600000; print "#{$F[0]} #{$F[1]} #{$F[2]}LL"'
133 // Magic numbers taken from
134 // http://stackoverflow.com/questions/5398557/
135 // java-library-for-dealing-with-win32-filetime .
137 // Now we store them in Java format (ms since the Unix epoch).
138 #define META_PROTO_TIMES_1 1263522064032LL
139 #define META_PROTO_TIMES_2 1253215061848LL
140 #define META_PROTO_TIMES_4 1255742764269LL
141 #define META_PROTO_TIMES_5 1255681950000LL
142 #define META_PROTO_TIMES_6 1260924017000LL
143 #define META_PROTO_TIMES_7 1253212875848LL
144 #define META_PROTO_TIMES_8 1253212875848LL
145 #define META_PROTO_TIMES_9 1253212875848LL
146 #define META_PROTO_TIMES_10 1253212875848LL
147 #define META_PROTO_TIMES_11 1263522094844LL
148 #define META_PROTO_TIMES_12 1263522151365LL
149 #define META_PROTO_TIMES_13 1263522198530LL
150 #define META_PROTO_TIMES_14 1263522238300LL
152 #define META_PROTO_TIMES_STR_1 "1263522064032"
153 #define META_PROTO_TIMES_STR_2 "1253215061848"
154 #define META_PROTO_TIMES_STR_4 "1255742764269"
155 #define META_PROTO_TIMES_STR_5 "1255681950000"
156 #define META_PROTO_TIMES_STR_6 "1260924017000"
157 #define META_PROTO_TIMES_STR_7 "1253212875848"
158 #define META_PROTO_TIMES_STR_8 "1253212875848"
159 #define META_PROTO_TIMES_STR_9 "1253212875848"
160 #define META_PROTO_TIMES_STR_10 "1253212875848"
161 #define META_PROTO_TIMES_STR_11 "1263522094844"
162 #define META_PROTO_TIMES_STR_12 "1263522151365"
163 #define META_PROTO_TIMES_STR_13 "1263522198530"
164 #define META_PROTO_TIMES_STR_14 "1263522238300"
166 #else
168 // On other platforms, we used to store timestamps in time_t format (s
169 // since the Unix epoch).
170 #define LEGACY_META_PROTO_TIMES_1 1263522064LL
171 #define LEGACY_META_PROTO_TIMES_2 1253215061LL
172 #define LEGACY_META_PROTO_TIMES_4 1255742764LL
173 #define LEGACY_META_PROTO_TIMES_5 1255681950LL
174 #define LEGACY_META_PROTO_TIMES_6 1260924017LL
175 #define LEGACY_META_PROTO_TIMES_7 1253212875LL
176 #define LEGACY_META_PROTO_TIMES_8 1253212875LL
177 #define LEGACY_META_PROTO_TIMES_9 1253212875LL
178 #define LEGACY_META_PROTO_TIMES_10 1253212875LL
179 #define LEGACY_META_PROTO_TIMES_11 1263522094LL
180 #define LEGACY_META_PROTO_TIMES_12 1263522151LL
181 #define LEGACY_META_PROTO_TIMES_13 1263522198LL
182 #define LEGACY_META_PROTO_TIMES_14 1263522238LL
184 #define LEGACY_META_PROTO_TIMES_STR_1 "1263522064"
185 #define LEGACY_META_PROTO_TIMES_STR_2 "1253215061"
186 #define LEGACY_META_PROTO_TIMES_STR_4 "1255742764"
187 #define LEGACY_META_PROTO_TIMES_STR_5 "1255681950"
188 #define LEGACY_META_PROTO_TIMES_STR_6 "1260924017"
189 #define LEGACY_META_PROTO_TIMES_STR_7 "1253212875"
190 #define LEGACY_META_PROTO_TIMES_STR_8 "1253212875"
191 #define LEGACY_META_PROTO_TIMES_STR_9 "1253212875"
192 #define LEGACY_META_PROTO_TIMES_STR_10 "1253212875"
193 #define LEGACY_META_PROTO_TIMES_STR_11 "1263522094"
194 #define LEGACY_META_PROTO_TIMES_STR_12 "1263522151"
195 #define LEGACY_META_PROTO_TIMES_STR_13 "1263522198"
196 #define LEGACY_META_PROTO_TIMES_STR_14 "1263522238"
198 // Now we store them in Java format (ms since the Unix epoch).
199 #define META_PROTO_TIMES_1 1263522064000LL
200 #define META_PROTO_TIMES_2 1253215061000LL
201 #define META_PROTO_TIMES_4 1255742764000LL
202 #define META_PROTO_TIMES_5 1255681950000LL
203 #define META_PROTO_TIMES_6 1260924017000LL
204 #define META_PROTO_TIMES_7 1253212875000LL
205 #define META_PROTO_TIMES_8 1253212875000LL
206 #define META_PROTO_TIMES_9 1253212875000LL
207 #define META_PROTO_TIMES_10 1253212875000LL
208 #define META_PROTO_TIMES_11 1263522094000LL
209 #define META_PROTO_TIMES_12 1263522151000LL
210 #define META_PROTO_TIMES_13 1263522198000LL
211 #define META_PROTO_TIMES_14 1263522238000LL
213 #define META_PROTO_TIMES_STR_1 "1263522064000"
214 #define META_PROTO_TIMES_STR_2 "1253215061000"
215 #define META_PROTO_TIMES_STR_4 "1255742764000"
216 #define META_PROTO_TIMES_STR_5 "1255681950000"
217 #define META_PROTO_TIMES_STR_6 "1260924017000"
218 #define META_PROTO_TIMES_STR_7 "1253212875000"
219 #define META_PROTO_TIMES_STR_8 "1253212875000"
220 #define META_PROTO_TIMES_STR_9 "1253212875000"
221 #define META_PROTO_TIMES_STR_10 "1253212875000"
222 #define META_PROTO_TIMES_STR_11 "1263522094000"
223 #define META_PROTO_TIMES_STR_12 "1263522151000"
224 #define META_PROTO_TIMES_STR_13 "1263522198000"
225 #define META_PROTO_TIMES_STR_14 "1263522238000"
227 #endif
229 // Helper macros for the database dumps in the SetUpVersion*Database
230 // functions.
231 #define LEGACY_META_PROTO_TIMES(x) LEGACY_META_PROTO_TIMES_##x
232 #define LEGACY_META_PROTO_TIMES_STR(x) LEGACY_META_PROTO_TIMES_STR_##x
233 #define LEGACY_PROTO_TIME_VALS(x) \
234 LEGACY_META_PROTO_TIMES_STR(x) "," \
235 LEGACY_META_PROTO_TIMES_STR(x) "," \
236 LEGACY_META_PROTO_TIMES_STR(x) "," \
237 LEGACY_META_PROTO_TIMES_STR(x)
238 #define META_PROTO_TIMES(x) META_PROTO_TIMES_##x
239 #define META_PROTO_TIMES_STR(x) META_PROTO_TIMES_STR_##x
240 #define META_PROTO_TIMES_VALS(x) \
241 META_PROTO_TIMES_STR(x) "," \
242 META_PROTO_TIMES_STR(x) "," \
243 META_PROTO_TIMES_STR(x) "," \
244 META_PROTO_TIMES_STR(x)
246 namespace {
248 // Helper functions for testing.
250 enum ShouldIncludeDeletedItems {
251 INCLUDE_DELETED_ITEMS,
252 DONT_INCLUDE_DELETED_ITEMS
255 // Returns a map from metahandle -> expected legacy time (in proto
256 // format).
257 std::map<int64, int64> GetExpectedLegacyMetaProtoTimes(
258 enum ShouldIncludeDeletedItems include_deleted) {
259 std::map<int64, int64> expected_legacy_meta_proto_times;
260 expected_legacy_meta_proto_times[1] = LEGACY_META_PROTO_TIMES(1);
261 if (include_deleted == INCLUDE_DELETED_ITEMS) {
262 expected_legacy_meta_proto_times[2] = LEGACY_META_PROTO_TIMES(2);
263 expected_legacy_meta_proto_times[4] = LEGACY_META_PROTO_TIMES(4);
264 expected_legacy_meta_proto_times[5] = LEGACY_META_PROTO_TIMES(5);
266 expected_legacy_meta_proto_times[6] = LEGACY_META_PROTO_TIMES(6);
267 expected_legacy_meta_proto_times[7] = LEGACY_META_PROTO_TIMES(7);
268 expected_legacy_meta_proto_times[8] = LEGACY_META_PROTO_TIMES(8);
269 expected_legacy_meta_proto_times[9] = LEGACY_META_PROTO_TIMES(9);
270 expected_legacy_meta_proto_times[10] = LEGACY_META_PROTO_TIMES(10);
271 expected_legacy_meta_proto_times[11] = LEGACY_META_PROTO_TIMES(11);
272 expected_legacy_meta_proto_times[12] = LEGACY_META_PROTO_TIMES(12);
273 expected_legacy_meta_proto_times[13] = LEGACY_META_PROTO_TIMES(13);
274 expected_legacy_meta_proto_times[14] = LEGACY_META_PROTO_TIMES(14);
275 return expected_legacy_meta_proto_times;
278 // Returns a map from metahandle -> expected time (in proto format).
279 std::map<int64, int64> GetExpectedMetaProtoTimes(
280 enum ShouldIncludeDeletedItems include_deleted) {
281 std::map<int64, int64> expected_meta_proto_times;
282 expected_meta_proto_times[1] = META_PROTO_TIMES(1);
283 if (include_deleted == INCLUDE_DELETED_ITEMS) {
284 expected_meta_proto_times[2] = META_PROTO_TIMES(2);
285 expected_meta_proto_times[4] = META_PROTO_TIMES(4);
286 expected_meta_proto_times[5] = META_PROTO_TIMES(5);
288 expected_meta_proto_times[6] = META_PROTO_TIMES(6);
289 expected_meta_proto_times[7] = META_PROTO_TIMES(7);
290 expected_meta_proto_times[8] = META_PROTO_TIMES(8);
291 expected_meta_proto_times[9] = META_PROTO_TIMES(9);
292 expected_meta_proto_times[10] = META_PROTO_TIMES(10);
293 expected_meta_proto_times[11] = META_PROTO_TIMES(11);
294 expected_meta_proto_times[12] = META_PROTO_TIMES(12);
295 expected_meta_proto_times[13] = META_PROTO_TIMES(13);
296 expected_meta_proto_times[14] = META_PROTO_TIMES(14);
297 return expected_meta_proto_times;
300 // Returns a map from metahandle -> expected time (as a Time object).
301 std::map<int64, base::Time> GetExpectedMetaTimes() {
302 std::map<int64, base::Time> expected_meta_times;
303 const std::map<int64, int64>& expected_meta_proto_times =
304 GetExpectedMetaProtoTimes(INCLUDE_DELETED_ITEMS);
305 for (std::map<int64, int64>::const_iterator it =
306 expected_meta_proto_times.begin();
307 it != expected_meta_proto_times.end(); ++it) {
308 expected_meta_times[it->first] = ProtoTimeToTime(it->second);
310 return expected_meta_times;
313 // Extracts a map from metahandle -> time (in proto format) from the
314 // given database.
315 std::map<int64, int64> GetMetaProtoTimes(sql::Connection *db) {
316 sql::Statement s(db->GetCachedStatement(
317 SQL_FROM_HERE,
318 "SELECT metahandle, mtime, server_mtime, ctime, server_ctime "
319 "FROM metas"));
320 EXPECT_EQ(5, s.ColumnCount());
321 std::map<int64, int64> meta_times;
322 while (s.Step()) {
323 int64 metahandle = s.ColumnInt64(0);
324 int64 mtime = s.ColumnInt64(1);
325 int64 server_mtime = s.ColumnInt64(2);
326 int64 ctime = s.ColumnInt64(3);
327 int64 server_ctime = s.ColumnInt64(4);
328 EXPECT_EQ(mtime, server_mtime);
329 EXPECT_EQ(mtime, ctime);
330 EXPECT_EQ(mtime, server_ctime);
331 meta_times[metahandle] = mtime;
333 EXPECT_TRUE(s.Succeeded());
334 return meta_times;
337 ::testing::AssertionResult AssertTimesMatch(const char* t1_expr,
338 const char* t2_expr,
339 const base::Time& t1,
340 const base::Time& t2) {
341 if (t1 == t2)
342 return ::testing::AssertionSuccess();
344 return ::testing::AssertionFailure()
345 << t1_expr << " and " << t2_expr
346 << " (internal values: " << t1.ToInternalValue()
347 << " and " << t2.ToInternalValue()
348 << ") (proto time: " << TimeToProtoTime(t1)
349 << " and " << TimeToProtoTime(t2)
350 << ") do not match";
353 // Expect that all time fields of the given entry kernel will be the
354 // given time.
355 void ExpectTime(const EntryKernel& entry_kernel,
356 const base::Time& expected_time) {
357 EXPECT_PRED_FORMAT2(AssertTimesMatch,
358 expected_time, entry_kernel.ref(CTIME));
359 EXPECT_PRED_FORMAT2(AssertTimesMatch,
360 expected_time, entry_kernel.ref(SERVER_CTIME));
361 EXPECT_PRED_FORMAT2(AssertTimesMatch,
362 expected_time, entry_kernel.ref(MTIME));
363 EXPECT_PRED_FORMAT2(AssertTimesMatch,
364 expected_time, entry_kernel.ref(SERVER_MTIME));
367 // Expect that all the entries in |entries| have times matching those in
368 // the given map (from metahandle to expect time).
369 void ExpectTimes(const Directory::MetahandlesMap& handles_map,
370 const std::map<int64, base::Time>& expected_times) {
371 for (Directory::MetahandlesMap::const_iterator it = handles_map.begin();
372 it != handles_map.end(); ++it) {
373 int64 meta_handle = it->first;
374 SCOPED_TRACE(meta_handle);
375 std::map<int64, base::Time>::const_iterator it2 =
376 expected_times.find(meta_handle);
377 if (it2 == expected_times.end()) {
378 ADD_FAILURE() << "Could not find expected time for " << meta_handle;
379 continue;
381 ExpectTime(*it->second, it2->second);
385 } // namespace
387 void MigrationTest::SetUpVersion67Database(sql::Connection* connection) {
388 // This is a version 67 database dump whose contents were backformed from
389 // the contents of the version 68 database dump (the v68 migration was
390 // actually written first).
391 ASSERT_TRUE(connection->is_open());
392 ASSERT_TRUE(connection->BeginTransaction());
393 ASSERT_TRUE(connection->Execute(
394 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
395 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
396 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL,"
397 "base_version bigint default -1,server_version bigint default 0,"
398 "mtime bigint default 0,server_mtime bigint default 0,"
399 "ctime bigint default 0,server_ctime bigint default 0,"
400 "server_position_in_parent bigint default 0,"
401 "local_external_id bigint default 0,id varchar(255) default 'r',"
402 "parent_id varchar(255) default 'r',"
403 "server_parent_id varchar(255) default 'r',"
404 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
405 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
406 "is_del bit default 0,is_dir bit default 0,"
407 "is_bookmark_object bit default 0,server_is_dir bit default 0,"
408 "server_is_del bit default 0,server_is_bookmark_object bit default 0,"
409 "name varchar(255), " /* COLLATE PATHNAME, */
410 "unsanitized_name varchar(255)," /* COLLATE PATHNAME, */
411 "non_unique_name varchar,"
412 "server_name varchar(255)," /* COLLATE PATHNAME */
413 "server_non_unique_name varchar,"
414 "bookmark_url varchar,server_bookmark_url varchar,"
415 "singleton_tag varchar,bookmark_favicon blob,"
416 "server_bookmark_favicon blob);"
417 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
418 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,"
419 "NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);"
420 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
421 ",-2097152,"
422 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"
423 "'Deleted Item',NULL,'Deleted Item','Deleted Item','Deleted Item',"
424 "'http://www.google.com/','http://www.google.com/2',NULL,'AASGASGA',"
425 "'ASADGADGADG');"
426 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
427 ",-3145728,"
428 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"
429 "'Welcome to Chromium',NULL,'Welcome to Chromium',"
430 "'Welcome to Chromium','Welcome to Chromium',"
431 "'http://www.google.com/chrome/intl/en/welcome.html',"
432 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,"
433 "NULL);"
434 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
435 ",1048576,"
436 "7,'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"
437 "'Google',NULL,'Google','Google','Google','http://www.google.com/',"
438 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG');"
439 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
440 ",-4194304,"
441 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,"
442 "'The Internet',NULL,'The Internet','The Internet',"
443 "'The Internet',NULL,NULL,NULL,NULL,NULL);"
444 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
446 "1048576,0,'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,"
447 "'Google Chrome',NULL,'Google Chrome','Google Chrome',"
448 "'Google Chrome',NULL,NULL,'google_chrome',NULL,NULL);"
449 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
450 ",1048576,"
451 "0,'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"
452 "NULL,'Bookmarks','Bookmarks','Bookmarks',NULL,NULL,"
453 "'google_chrome_bookmarks',NULL,NULL);"
454 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
456 "1048576,1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,"
457 "1,'Bookmark Bar',NULL,'Bookmark Bar','Bookmark Bar','Bookmark Bar',"
458 "NULL,NULL,'bookmark_bar',NULL,NULL);"
459 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
460 ",2097152,"
461 "2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"
462 "'Other Bookmarks',NULL,'Other Bookmarks','Other Bookmarks',"
463 "'Other Bookmarks',NULL,NULL,'other_bookmarks',"
464 "NULL,NULL);"
465 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
466 ",-1048576,"
467 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"
468 "'Home (The Chromium Projects)',NULL,'Home (The Chromium Projects)',"
469 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
470 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"
471 "'AGATWA','AFAGVASF');"
472 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
473 ",0,9,"
474 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"
475 "'Extra Bookmarks',NULL,'Extra Bookmarks','Extra Bookmarks',"
476 "'Extra Bookmarks',NULL,NULL,NULL,NULL,NULL);"
477 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
478 ",-917504,"
479 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"
480 "1,'ICANN | Internet Corporation for Assigned Names and Numbers',"
481 "'ICANN Internet Corporation for Assigned Names and Numbers',"
482 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
483 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
484 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
485 "'http://www.icann.com/','http://www.icann.com/',NULL,"
486 "'PNGAXF0AAFF','DAAFASF');"
487 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
488 ",1048576,"
489 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"
490 "'The WebKit Open Source Project',NULL,"
491 "'The WebKit Open Source Project','The WebKit Open Source Project',"
492 "'The WebKit Open Source Project','http://webkit.org/',"
493 "'http://webkit.org/x',NULL,'PNGX','PNG2Y');"
494 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
495 "last_sync_timestamp INT, name VARCHAR(128), "
496 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
497 "db_create_version VARCHAR(128), db_create_time int, "
498 "next_id bigint default -2, cache_guid VARCHAR(32));"
499 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
500 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
501 "'Unknown',1263522064,-65542,"
502 "'9010788312004066376x-6609234393368420856x');"
503 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
504 "INSERT INTO share_version VALUES('nick@chromium.org',68);"));
505 ASSERT_TRUE(connection->CommitTransaction());
508 void MigrationTest::SetUpVersion68Database(sql::Connection* connection) {
509 // This sets up an actual version 68 database dump. The IDs were
510 // canonicalized to be less huge, and the favicons were overwritten
511 // with random junk so that they didn't contain any unprintable
512 // characters. A few server URLs were tweaked so that they'd be
513 // different from the local URLs. Lastly, the custom collation on
514 // the server_non_unique_name column was removed.
515 ASSERT_TRUE(connection->is_open());
516 ASSERT_TRUE(connection->BeginTransaction());
517 ASSERT_TRUE(connection->Execute(
518 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
519 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
520 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL,"
521 "base_version bigint default -1,server_version bigint default 0,"
522 "mtime bigint default 0,server_mtime bigint default 0,"
523 "ctime bigint default 0,server_ctime bigint default 0,"
524 "server_position_in_parent bigint default 0,"
525 "local_external_id bigint default 0,id varchar(255) default 'r',"
526 "parent_id varchar(255) default 'r',"
527 "server_parent_id varchar(255) default 'r',"
528 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
529 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
530 "is_del bit default 0,is_dir bit default 0,"
531 "is_bookmark_object bit default 0,server_is_dir bit default 0,"
532 "server_is_del bit default 0,"
533 "server_is_bookmark_object bit default 0,"
534 "non_unique_name varchar,server_non_unique_name varchar(255),"
535 "bookmark_url varchar,server_bookmark_url varchar,"
536 "singleton_tag varchar,bookmark_favicon blob,"
537 "server_bookmark_favicon blob);"
538 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
539 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,"
540 "NULL,NULL,NULL,NULL,NULL,NULL);"
541 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
542 ",-2097152,"
543 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"
544 "'Deleted Item','Deleted Item','http://www.google.com/',"
545 "'http://www.google.com/2',NULL,'AASGASGA','ASADGADGADG');"
546 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
547 ",-3145728,"
548 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"
549 "'Welcome to Chromium','Welcome to Chromium',"
550 "'http://www.google.com/chrome/intl/en/welcome.html',"
551 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,"
552 "NULL);"
553 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
554 ",1048576,"
555 "7,'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"
556 "'Google','Google','http://www.google.com/',"
557 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG');"
558 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
559 ",-4194304,"
560 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,"
561 "'The Internet','The Internet',NULL,NULL,NULL,NULL,NULL);"
562 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
564 "1048576,0,'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,"
565 "'Google Chrome','Google Chrome',NULL,NULL,'google_chrome',NULL,"
566 "NULL);"
567 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
568 ",1048576,"
569 "0,'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"
570 "'Bookmarks',NULL,NULL,'google_chrome_bookmarks',NULL,NULL);"
571 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
573 "1048576,1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,"
574 "1,'Bookmark Bar','Bookmark Bar',NULL,NULL,'bookmark_bar',NULL,"
575 "NULL);"
576 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
577 ",2097152,"
578 "2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"
579 "'Other Bookmarks','Other Bookmarks',NULL,NULL,'other_bookmarks',"
580 "NULL,NULL);"
581 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
582 ",-1048576,"
583 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"
584 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
585 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"
586 "'AGATWA','AFAGVASF');"
587 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
588 ",0,9,"
589 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"
590 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,NULL,NULL,NULL);"
591 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
592 ",-917504,"
593 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"
594 "1,'ICANN | Internet Corporation for Assigned Names and Numbers',"
595 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
596 "'http://www.icann.com/','http://www.icann.com/',NULL,"
597 "'PNGAXF0AAFF','DAAFASF');"
598 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
599 ",1048576,"
600 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"
601 "'The WebKit Open Source Project','The WebKit Open Source Project',"
602 "'http://webkit.org/','http://webkit.org/x',NULL,'PNGX','PNG2Y');"
603 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
604 "last_sync_timestamp INT, name VARCHAR(128), "
605 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
606 "db_create_version VARCHAR(128), db_create_time int, "
607 "next_id bigint default -2, cache_guid VARCHAR(32));"
608 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
609 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
610 "'Unknown',1263522064,-65542,"
611 "'9010788312004066376x-6609234393368420856x');"
612 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
613 "INSERT INTO share_version VALUES('nick@chromium.org',68);"));
614 ASSERT_TRUE(connection->CommitTransaction());
617 void MigrationTest::SetUpVersion69Database(sql::Connection* connection) {
618 ASSERT_TRUE(connection->is_open());
619 ASSERT_TRUE(connection->BeginTransaction());
620 ASSERT_TRUE(connection->Execute(
621 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
622 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
623 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL,"
624 "base_version bigint default -1,server_version bigint default 0,"
625 "mtime bigint default 0,server_mtime bigint default 0,"
626 "ctime bigint default 0,server_ctime bigint default 0,"
627 "server_position_in_parent bigint default 0,"
628 "local_external_id bigint default 0,id varchar(255) default 'r',"
629 "parent_id varchar(255) default 'r',"
630 "server_parent_id varchar(255) default 'r',"
631 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
632 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
633 "is_del bit default 0,is_dir bit default 0,"
634 "is_bookmark_object bit default 0,server_is_dir bit default 0,"
635 "server_is_del bit default 0,"
636 "server_is_bookmark_object bit default 0,"
637 "non_unique_name varchar,server_non_unique_name varchar(255),"
638 "bookmark_url varchar,server_bookmark_url varchar,"
639 "singleton_tag varchar,bookmark_favicon blob,"
640 "server_bookmark_favicon blob, specifics blob, "
641 "server_specifics blob);"
642 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
643 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,NULL,NULL,NULL,NULL,"
644 "NULL,NULL,X'',X'');"
645 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
646 ",-2097152,"
647 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"
648 "'Deleted Item','Deleted Item','http://www.google.com/',"
649 "'http://www.google.com/2',NULL,'AASGASGA','ASADGADGADG',"
650 "X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F120841415"
651 "34741534741',X'C28810260A17687474703A2F2F7777772E676F6F676C652E636F"
652 "6D2F32120B4153414447414447414447');"
653 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
654 ",-3145728,"
655 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"
656 "'Welcome to Chromium','Welcome to Chromium',"
657 "'http://www.google.com/chrome/intl/en/welcome.html',"
658 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,NULL,"
659 "X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
660 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A3168"
661 "7474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F6"
662 "56E2F77656C636F6D652E68746D6C1200');"
663 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
664 ",1048576,7,"
665 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"
666 "'Google','Google','http://www.google.com/',"
667 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG',X'C28810220A166"
668 "87474703A2F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'"
669 "C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464"
670 "447415347');"
671 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
672 ",-4194304,6"
673 ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,'The Internet',"
674 "'The Internet',NULL,NULL,NULL,NULL,NULL,X'C2881000',X'C2881000');"
675 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
676 ",1048576,0,"
677 "'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,'Google Chrome',"
678 "'Google Chrome',NULL,NULL,'google_chrome',NULL,NULL,NULL,NULL);"
679 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
680 ",1048576,0,"
681 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"
682 "'Bookmarks',NULL,NULL,'google_chrome_bookmarks',NULL,NULL,"
683 "X'C2881000',X'C2881000');"
684 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
685 ",1048576,1,"
686 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,1,"
687 "'Bookmark Bar','Bookmark Bar',NULL,NULL,'bookmark_bar',NULL,NULL,"
688 "X'C2881000',X'C2881000');"
689 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
690 ",2097152,2,"
691 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"
692 "'Other Bookmarks','Other Bookmarks',NULL,NULL,'other_bookmarks',"
693 "NULL,NULL,X'C2881000',X'C2881000');"
694 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
695 ",-1048576,"
696 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"
697 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
698 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"
699 "'AGATWA','AFAGVASF',X'C28810220A18687474703A2F2F6465762E6368726F6D6"
700 "9756D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F646576"
701 "2E6368726F6D69756D2E6F72672F6F7468657212084146414756415346');"
702 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
703 ",0,9,"
704 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"
705 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,NULL,NULL,NULL,"
706 "X'C2881000',X'C2881000');"
707 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
708 ",-917504,"
709 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"
710 "1,'ICANN | Internet Corporation for Assigned Names and Numbers',"
711 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
712 "'http://www.icann.com/','http://www.icann.com/',NULL,'PNGAXF0AAFF',"
713 "'DAAFASF',X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F1"
714 "20B504E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963"
715 "616E6E2E636F6D2F120744414146415346');"
716 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
717 ",1048576,11,"
718 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"
719 "'The WebKit Open Source Project','The WebKit Open Source Project',"
720 "'http://webkit.org/','http://webkit.org/x',NULL,'PNGX','PNG2Y',"
721 "X'C288101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C2"
722 "88101C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259');"
723 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
724 "last_sync_timestamp INT, name VARCHAR(128), "
725 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
726 "db_create_version VARCHAR(128), db_create_time int, "
727 "next_id bigint default -2, cache_guid VARCHAR(32));"
728 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
729 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
730 "'Unknown',1263522064,-65542,"
731 "'9010788312004066376x-6609234393368420856x');"
732 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
733 "INSERT INTO share_version VALUES('nick@chromium.org',69);"
735 ASSERT_TRUE(connection->CommitTransaction());
738 void MigrationTest::SetUpVersion70Database(sql::Connection* connection) {
739 ASSERT_TRUE(connection->is_open());
740 ASSERT_TRUE(connection->BeginTransaction());
741 ASSERT_TRUE(connection->Execute(
742 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
743 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
744 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
745 "last_sync_timestamp INT, name VARCHAR(128), "
746 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
747 "db_create_version VARCHAR(128), db_create_time int, "
748 "next_id bigint default -2, cache_guid VARCHAR(32));"
749 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
750 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
751 "'Unknown',1263522064,-65542,"
752 "'9010788312004066376x-6609234393368420856x');"
753 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
754 "INSERT INTO share_version VALUES('nick@chromium.org',70);"
755 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
756 "base_version bigint default -1,server_version bigint default 0,"
757 "mtime bigint default 0,server_mtime bigint default 0,"
758 "ctime bigint default 0,server_ctime bigint default 0,"
759 "server_position_in_parent bigint default 0,"
760 "local_external_id bigint default 0,id varchar(255) default 'r',"
761 "parent_id varchar(255) default 'r',"
762 "server_parent_id varchar(255) default 'r',"
763 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
764 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
765 "is_del bit default 0,is_dir bit default 0,"
766 "server_is_dir bit default 0,server_is_del bit default 0,"
767 "non_unique_name varchar,server_non_unique_name varchar(255),"
768 "unique_server_tag varchar,unique_client_tag varchar,"
769 "specifics blob,server_specifics blob);"
770 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
771 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'');"
772 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2) ","
773 "-2097152,4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,"
774 "1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A"
775 "2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X'C2881026"
776 "0A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B415341444741"
777 "4447414447');"
778 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
779 ",-3145728,"
780 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
781 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A"
782 "31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E74"
783 "6C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F"
784 "2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F7765"
785 "6C636F6D652E68746D6C1200');"
786 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
787 ",1048576,7,"
788 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
789 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C6"
790 "52E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F77777"
791 "72E676F6F676C652E636F6D2F12084147464447415347');"
792 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
793 ",-4194304,"
794 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
795 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
796 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
797 ",1048576,0,"
798 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome',"
799 "'Google Chrome','google_chrome',NULL,NULL,NULL);"
800 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
801 ",1048576,0,"
802 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
803 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',"
804 "X'C2881000');"
805 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
806 ",1048576,"
807 "1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,"
808 "'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881000',"
809 "X'C2881000');"
810 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
812 "2097152,2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
813 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
814 "X'C2881000',X'C2881000');"
815 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
816 ",-1048576,"
817 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
818 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
819 "NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F"
820 "72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636872"
821 "6F6D69756D2E6F72672F6F7468657212084146414756415346');"
822 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
823 ",0,9,"
824 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
825 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
826 "X'C2881000');"
827 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
828 ",-917504,"
829 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
830 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
831 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
832 "NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F"
833 "120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772E69"
834 "63616E6E2E636F6D2F120744414146415346');"
835 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
836 ",1048576,"
837 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
838 "'The WebKit Open Source Project','The WebKit Open Source Project',"
839 "NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
840 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F78120550"
841 "4E473259');"
843 ASSERT_TRUE(connection->CommitTransaction());
846 void MigrationTest::SetUpVersion71Database(sql::Connection* connection) {
847 ASSERT_TRUE(connection->is_open());
848 ASSERT_TRUE(connection->BeginTransaction());
849 ASSERT_TRUE(connection->Execute(
850 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
851 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
852 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
853 "INSERT INTO 'share_version' VALUES('nick@chromium.org',71);"
854 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
855 "base_version bigint default -1,server_version bigint default 0,"
856 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint "
857 "default 0,server_ctime bigint default 0,server_position_in_parent "
858 "bigint default 0,local_external_id bigint default 0,id varchar(255) "
859 "default 'r',parent_id varchar(255) default 'r',server_parent_id "
860 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id "
861 "varchar(255) default 'r',is_unsynced bit default 0,"
862 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit "
863 "default 0,server_is_dir bit default 0,server_is_del bit default 0,"
864 "non_unique_name varchar,server_non_unique_name varchar(255),"
865 "unique_server_tag varchar,unique_client_tag varchar,specifics blob,"
866 "server_specifics blob);"
867 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
868 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"
869 "NULL,NULL,X'',X'');"
870 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
871 ",-2097152,4,"
872 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"
873 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"
874 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"
875 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"
876 "47');"
877 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
878 ",-3145728,3,"
879 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
880 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"
881 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"
882 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"
883 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"
884 "652E68746D6C1200');"
885 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
886 ",1048576,7,"
887 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
888 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"
889 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"
890 "76F6F676C652E636F6D2F12084147464447415347');"
891 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
892 ",-4194304,6,"
893 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
894 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
895 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
896 ",1048576,0,"
897 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"
898 ",'google_chrome',NULL,NULL,NULL);"
899 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
900 ",1048576,0,"
901 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
902 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
903 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
904 ",1048576,1,"
905 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"
906 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
907 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
908 ",2097152,2,"
909 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
910 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
911 "X'C2881000',X'C2881000');"
912 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
913 ",-1048576,8,"
914 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
915 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"
916 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"
917 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
918 "D2E6F72672F6F7468657212084146414756415346');"
919 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
920 ",0,9,"
921 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
922 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
923 "X'C2881000');"
924 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
925 ",-917504,10,"
926 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
927 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
928 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"
929 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
930 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"
931 "E636F6D2F120744414146415346');"
932 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
933 ",1048576,11,"
934 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
935 "'The WebKit Open Source Project','The WebKit Open Source Project',"
936 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
937 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E"
938 "473259');"
939 "CREATE TABLE models (model_id BLOB primary key, "
940 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);"
941 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
942 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, "
943 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, "
944 "next_id INT default -2, cache_guid TEXT);"
945 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
946 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,"
947 "'9010788312004066376x-6609234393368420856x');"));
948 ASSERT_TRUE(connection->CommitTransaction());
951 void MigrationTest::SetUpVersion72Database(sql::Connection* connection) {
952 ASSERT_TRUE(connection->is_open());
953 ASSERT_TRUE(connection->BeginTransaction());
954 ASSERT_TRUE(connection->Execute(
955 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
956 "INSERT INTO 'share_version' VALUES('nick@chromium.org',72);"
957 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
958 "base_version bigint default -1,server_version bigint default 0,"
959 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint "
960 "default 0,server_ctime bigint default 0,server_position_in_parent "
961 "bigint default 0,local_external_id bigint default 0,id varchar(255) "
962 "default 'r',parent_id varchar(255) default 'r',server_parent_id "
963 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id "
964 "varchar(255) default 'r',is_unsynced bit default 0,"
965 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit "
966 "default 0,server_is_dir bit default 0,server_is_del bit default 0,"
967 "non_unique_name varchar,server_non_unique_name varchar(255),"
968 "unique_server_tag varchar,unique_client_tag varchar,specifics blob,"
969 "server_specifics blob);"
970 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
971 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"
972 "NULL,NULL,X'',X'');"
973 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
974 ",-2097152,4,"
975 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"
976 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"
977 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"
978 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"
979 "47');"
980 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
981 ",-3145728,3,"
982 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
983 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"
984 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"
985 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"
986 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"
987 "652E68746D6C1200');"
988 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
989 ",1048576,7,"
990 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
991 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"
992 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"
993 "76F6F676C652E636F6D2F12084147464447415347');"
994 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
995 ",-4194304,6,"
996 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
997 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
998 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
999 ",1048576,0,"
1000 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"
1001 ",'google_chrome',NULL,NULL,NULL);"
1002 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1003 ",1048576,0,"
1004 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
1005 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1006 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1007 ",1048576,1,"
1008 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"
1009 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1010 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1011 ",2097152,2,"
1012 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
1013 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
1014 "X'C2881000',X'C2881000');"
1015 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1016 ",-1048576,8,"
1017 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
1018 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"
1019 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"
1020 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
1021 "D2E6F72672F6F7468657212084146414756415346');"
1022 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1023 ",0,9,"
1024 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
1025 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
1026 "X'C2881000');"
1027 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1028 ",-917504,10,"
1029 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
1030 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
1031 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"
1032 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
1033 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"
1034 "E636F6D2F120744414146415346');"
1035 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1036 ",1048576,11,"
1037 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
1038 "'The WebKit Open Source Project','The WebKit Open Source Project',"
1039 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
1040 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E"
1041 "473259');"
1042 "CREATE TABLE models (model_id BLOB primary key, "
1043 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);"
1044 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
1045 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, "
1046 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, "
1047 "next_id INT default -2, cache_guid TEXT);"
1048 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1049 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,"
1050 "'9010788312004066376x-6609234393368420856x');"));
1051 ASSERT_TRUE(connection->CommitTransaction());
1054 void MigrationTest::SetUpVersion73Database(sql::Connection* connection) {
1055 ASSERT_TRUE(connection->is_open());
1056 ASSERT_TRUE(connection->BeginTransaction());
1057 ASSERT_TRUE(connection->Execute(
1058 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1059 "INSERT INTO 'share_version' VALUES('nick@chromium.org',73);"
1060 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
1061 "base_version bigint default -1,server_version bigint default 0,"
1062 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint "
1063 "default 0,server_ctime bigint default 0,server_position_in_parent "
1064 "bigint default 0,local_external_id bigint default 0,id varchar(255) "
1065 "default 'r',parent_id varchar(255) default 'r',server_parent_id "
1066 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id "
1067 "varchar(255) default 'r',is_unsynced bit default 0,"
1068 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit "
1069 "default 0,server_is_dir bit default 0,server_is_del bit default 0,"
1070 "non_unique_name varchar,server_non_unique_name varchar(255),"
1071 "unique_server_tag varchar,unique_client_tag varchar,specifics blob,"
1072 "server_specifics blob);"
1073 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1074 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"
1075 "NULL,NULL,X'',X'');"
1076 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1077 ",-2097152,4,"
1078 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"
1079 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"
1080 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"
1081 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"
1082 "47');"
1083 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1084 ",-3145728,3,"
1085 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
1086 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"
1087 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"
1088 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"
1089 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"
1090 "652E68746D6C1200');"
1091 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1092 ",1048576,7,"
1093 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
1094 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"
1095 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"
1096 "76F6F676C652E636F6D2F12084147464447415347');"
1097 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1098 ",-4194304,6,"
1099 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
1100 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
1101 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1102 ",1048576,0,"
1103 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"
1104 ",'google_chrome',NULL,NULL,NULL);"
1105 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1106 ",1048576,0,"
1107 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
1108 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1109 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1110 ",1048576,1,"
1111 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"
1112 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1113 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1114 ",2097152,2,"
1115 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
1116 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
1117 "X'C2881000',X'C2881000');"
1118 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1119 ",-1048576,8,"
1120 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
1121 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"
1122 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"
1123 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
1124 "D2E6F72672F6F7468657212084146414756415346');"
1125 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1126 ",0,9,"
1127 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
1128 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
1129 "X'C2881000');"
1130 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1131 ",-917504,10,"
1132 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
1133 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
1134 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"
1135 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
1136 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"
1137 "E636F6D2F120744414146415346');"
1138 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1139 ",1048576,11,"
1140 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
1141 "'The WebKit Open Source Project','The WebKit Open Source Project',"
1142 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
1143 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E"
1144 "473259');"
1145 "CREATE TABLE models (model_id BLOB primary key, "
1146 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);"
1147 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
1148 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, "
1149 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, "
1150 "next_id INT default -2, cache_guid TEXT, "
1151 "notification_state BLOB);"
1152 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1153 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,"
1154 "'9010788312004066376x-6609234393368420856x',X'C2881000');"));
1155 ASSERT_TRUE(connection->CommitTransaction());
1158 void MigrationTest::SetUpVersion74Database(sql::Connection* connection) {
1159 ASSERT_TRUE(connection->is_open());
1160 ASSERT_TRUE(connection->BeginTransaction());
1161 ASSERT_TRUE(connection->Execute(
1162 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1163 "INSERT INTO 'share_version' VALUES('nick@chromium.org',74);"
1164 "CREATE TABLE models (model_id BLOB primary key, last_download_timestamp"
1165 " INT, initial_sync_ended BOOLEAN default 0);"
1166 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
1167 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthd"
1168 "ay TEXT, db_create_version TEXT, db_create_time INT, next_id INT de"
1169 "fault -2, cache_guid TEXT , notification_state BLOB, autofill_migra"
1170 "tion_state INT default 0, bookmarks_added_during_autofill_migration"
1171 " INT default 0, autofill_migration_time INT default 0, autofill_ent"
1172 "ries_added_during_migration INT default 0, autofill_profiles_added_"
1173 "during_migration INT default 0);"
1174 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'"
1175 ",'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542"
1176 ",'9010788312004066376x-6609234393368420856x',NULL,0,0,0,0,0);"
1177 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,bas"
1178 "e_version bigint default -1,server_version bigint default 0,mtime b"
1179 "igint default 0,server_mtime bigint default 0,ctime bigint default "
1180 "0,server_ctime bigint default 0,server_position_in_parent bigint de"
1181 "fault 0,local_external_id bigint default 0,id varchar(255) default "
1182 "'r',parent_id varchar(255) default 'r',server_parent_id varchar(255"
1183 ") default 'r',prev_id varchar(255) default 'r',next_id varchar(255)"
1184 " default 'r',is_unsynced bit default 0,is_unapplied_update bit defa"
1185 "ult 0,is_del bit default 0,is_dir bit default 0,server_is_dir bit d"
1186 "efault 0,server_is_del bit default 0,non_unique_name varchar,server"
1187 "_non_unique_name varchar(255),unique_server_tag varchar,unique_clie"
1188 "nt_tag varchar,specifics blob,server_specifics blob);"
1189 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1190 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'"
1191 "');"
1192 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1193 ",-2097152,4,'s_ID_2','s_ID"
1194 "_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Item','Deleted "
1195 "Item',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E6"
1196 "36F6D2F12084141534741534741',X'C28810260A17687474703A2F2F7777772E67"
1197 "6F6F676C652E636F6D2F32120B4153414447414447414447');"
1198 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1199 ",-3145728,3,'s_ID_4','s_ID"
1200 "_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to Chromium','W"
1201 "elcome to Chromium',NULL,NULL,X'C28810350A31687474703A2F2F7777772E6"
1202 "76F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E"
1203 "68746D6C1200',X'C28810350A31687474703A2F2F7777772E676F6F676C652E636"
1204 "F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E68746D6C1200');"
1205 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1206 ",1048576,7,'s_ID_5','s_ID_"
1207 "9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Google',NULL,NU"
1208 "LL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F120841"
1209 "47415347415347',X'C28810220A16687474703A2F2F7777772E676F6F676C652E6"
1210 "36F6D2F12084147464447415347');"
1211 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1212 ",-4194304,6,'s_ID_6','s_ID"
1213 "_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The Internet',NULL"
1214 ",NULL,X'C2881000',X'C2881000');"
1215 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1216 ",1048576,0,'s_ID_7','r','r"
1217 "','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google_chrom"
1218 "e',NULL,NULL,NULL);"
1219 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1220 ",1048576,0,'s_ID_8','s_ID_"
1221 "7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks','google_chr"
1222 "ome_bookmarks',NULL,X'C2881000',X'C2881000');"
1223 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1224 ",1048576,1,'s_ID_9','s_ID_"
1225 "8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar'"
1226 ",'bookmark_bar',NULL,X'C2881000',X'C2881000');"
1227 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1228 ",2097152,2,'s_ID_10','s_I"
1229 "D_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks','Other Boo"
1230 "kmarks','other_bookmarks',NULL,X'C2881000',X'C2881000');"
1231 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1232 ",-1048576,8,'s_ID_11','s_"
1233 "ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chromium Projec"
1234 "ts)','Home (The Chromium Projects)',NULL,NULL,X'C28810220A186874747"
1235 "03A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741',X'C28810"
1236 "290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74686572120"
1237 "84146414756415346');"
1238 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1239 ",0,9,'s_ID_12','s_ID_6','"
1240 "s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bo"
1241 "okmarks',NULL,NULL,X'C2881000',X'C2881000');"
1242 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1243 ",-917504,10,'s_ID_13','s_"
1244 "ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN | Internet Co"
1245 "rporation for Assigned Names and Numbers','ICANN | Internet Corpora"
1246 "tion for Assigned Names and Numbers',NULL,NULL,X'C28810240A15687474"
1247 "703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',X'C"
1248 "28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F12074441414641"
1249 "5346');"
1250 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1251 ",1048576,11,'s_ID_14','s_"
1252 "ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Open Source Pr"
1253 "oject','The WebKit Open Source Project',NULL,NULL,X'C288101A0A12687"
1254 "474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101C0A13687474"
1255 "703A2F2F7765626B69742E6F72672F781205504E473259');"
1257 ASSERT_TRUE(connection->CommitTransaction());
1260 void MigrationTest::SetUpVersion75Database(sql::Connection* connection) {
1261 ASSERT_TRUE(connection->is_open());
1262 ASSERT_TRUE(connection->BeginTransaction());
1263 ASSERT_TRUE(connection->Execute(
1264 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1265 "INSERT INTO 'share_version' VALUES('nick@chromium.org',75);"
1266 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthd"
1267 "ay TEXT, db_create_version TEXT, db_create_time INT, next_id INT de"
1268 "fault -2, cache_guid TEXT , notification_state BLOB, autofill_migra"
1269 "tion_state INT default 0,bookmarks_added_during_autofill_migration "
1270 "INT default 0, autofill_migration_time INT default 0, autofill_entr"
1271 "ies_added_during_migration INT default 0, autofill_profiles_added_d"
1272 "uring_migration INT default 0);"
1273 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org"
1274 "','c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-655"
1275 "42,'9010788312004066376x-6609234393368420856x',NULL,0,0,0,0,0);"
1276 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, "
1277 "initial_sync_ended BOOLEAN default 0);"
1278 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1279 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,ba"
1280 "se_version bigint default -1,server_version bigint default 0,mtime"
1281 " bigint default 0,server_mtime bigint default 0,ctime bigint defau"
1282 "lt 0,server_ctime bigint default 0,server_position_in_parent bigin"
1283 "t default 0,local_external_id bigint default 0,id varchar(255) def"
1284 "ault 'r',parent_id varchar(255) default 'r',server_parent_id varch"
1285 "ar(255) default 'r',prev_id varchar(255) default 'r',next_id varch"
1286 "ar(255) default 'r',is_unsynced bit default 0,is_unapplied_update "
1287 "bit default 0,is_del bit default 0,is_dir bit default 0,server_is_"
1288 "dir bit default 0,server_is_del bit default 0,non_unique_name varc"
1289 "har,server_non_unique_name varchar(255),unique_server_tag varchar,"
1290 "unique_client_tag varchar,specifics blob,server_specifics blob);"
1291 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1292 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NUL"
1293 "L,X'',X'');"
1294 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1295 ",-2097152,4,'s_ID_"
1296 "2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Ite"
1297 "m','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F7777772"
1298 "E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A176874"
1299 "74703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474"
1300 "14447');"
1301 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1302 ",-3145728,3,'s_ID_"
1303 "4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to "
1304 "Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A316874747"
1305 "03A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F65"
1306 "6E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7"
1307 "777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F7765"
1308 "6C636F6D652E68746D6C1200');"
1309 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1310 ",1048576,7,'s_ID_5"
1311 "','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Goo"
1312 "gle',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C65"
1313 "2E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F777"
1314 "7772E676F6F676C652E636F6D2F12084147464447415347');"
1315 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1316 ",-4194304,6,'s_ID_"
1317 "6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The In"
1318 "ternet',NULL,NULL,X'C2881000',X'C2881000');"
1319 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1320 ",1048576,0,'s_ID_7"
1321 "','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','"
1322 "google_chrome',NULL,NULL,NULL);"
1323 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1324 ",1048576,0,'s_ID_8"
1325 "','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks'"
1326 ",'google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1327 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1328 ",1048576,1,'s_ID_9"
1329 "','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','B"
1330 "ookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1331 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1332 ",2097152,2,'s_ID_"
1333 "10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks"
1334 "','Other Bookmarks','other_bookmarks',NULL,X'C2881000',X'C28810"
1335 "00');"
1336 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1337 ",-1048576,8,'s_ID"
1338 "_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chr"
1339 "omium Projects)','Home (The Chromium Projects)',NULL,NULL,X'C28"
1340 "810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F120641"
1341 "4741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
1342 "D2E6F72672F6F7468657212084146414756415346');"
1343 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1344 ",0,9,'s_ID_12','s"
1345 "_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmark"
1346 "s','Extra Bookmarks',NULL,NULL,X'C2881000',X'C2881000');"
1347 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1348 ",-917504,10,'s_ID"
1349 "_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN |"
1350 " Internet Corporation for Assigned Names and Numbers','ICANN | "
1351 "Internet Corporation for Assigned Names and Numbers',NULL,NULL,"
1352 "X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
1353 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E696361"
1354 "6E6E2E636F6D2F120744414146415346');"
1355 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1356 ",1048576,11,'s_ID"
1357 "_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Op"
1358 "en Source Project','The WebKit Open Source Project',NULL,NULL,X"
1359 "'C288101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',"
1360 "X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E473"
1361 "259');"
1363 ASSERT_TRUE(connection->CommitTransaction());
1366 void MigrationTest::SetUpVersion76Database(sql::Connection* connection) {
1367 ASSERT_TRUE(connection->is_open());
1368 ASSERT_TRUE(connection->BeginTransaction());
1369 ASSERT_TRUE(connection->Execute(
1370 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1371 "INSERT INTO 'share_version' VALUES('nick@chromium.org',76);"
1372 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1373 "itial_sync_ended BOOLEAN default 0);"
1374 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1375 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1376 "_version bigint default -1,server_version bigint default 0,mtime big"
1377 "int default 0,server_mtime bigint default 0,ctime bigint default 0,s"
1378 "erver_ctime bigint default 0,server_position_in_parent bigint defaul"
1379 "t 0,local_external_id bigint default 0,id varchar(255) default 'r',p"
1380 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1381 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1382 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1383 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1384 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1385 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1386 "har,specifics blob,server_specifics blob);"
1387 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1388 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'')"
1390 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1391 ",-2097152,4,'s_ID_2','s_ID_9"
1392 "','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Item','Deleted Ite"
1393 "m',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6"
1394 "D2F12084141534741534741',X'C28810260A17687474703A2F2F7777772E676F6F6"
1395 "76C652E636F6D2F32120B4153414447414447414447');"
1396 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1397 ",-3145728,3,'s_ID_4','s_ID_9"
1398 "','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to Chromium','Welc"
1399 "ome to Chromium',NULL,NULL,X'C28810350A31687474703A2F2F7777772E676F6"
1400 "F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E68746"
1401 "D6C1200',X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6"
1402 "368726F6D652F696E746C2F656E2F77656C636F6D652E68746D6C1200');"
1403 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1404 ",1048576,7,'s_ID_5','s_ID_9'"
1405 ",'s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Google',NULL,NULL,"
1406 "X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F1208414741"
1407 "5347415347',X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D"
1408 "2F12084147464447415347');"
1409 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1410 ",-4194304,6,'s_ID_6','s_ID_9"
1411 "','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The Internet',NULL,NU"
1412 "LL,X'C2881000',X'C2881000');"
1413 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1414 ",1048576,0,'s_ID_7','r','r',"
1415 "'r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google_chrome',"
1416 "NULL,NULL,NULL);"
1417 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1418 ",1048576,0,'s_ID_8','s_ID_7'"
1419 ",'s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks','google_chrome"
1420 "_bookmarks',NULL,X'C2881000',X'C2881000');"
1421 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1422 ",1048576,1,'s_ID_9','s_ID_8'"
1423 ",'s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar','b"
1424 "ookmark_bar',NULL,X'C2881000',X'C2881000');"
1425 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1426 ",2097152,2,'s_ID_10','s_ID_"
1427 "8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks','Other Bookma"
1428 "rks','other_bookmarks',NULL,X'C2881000',X'C2881000');"
1429 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1430 ",-1048576,8,'s_ID_11','s_ID"
1431 "_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chromium Projects)"
1432 "','Home (The Chromium Projects)',NULL,NULL,X'C28810220A18687474703A2"
1433 "F2F6465762E6368726F6D69756D2E6F72672F1206414741545741',X'C28810290A1"
1434 "D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74686572120841464"
1435 "14756415346');"
1436 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1437 ",0,9,'s_ID_12','s_ID_6','s_"
1438 "ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookm"
1439 "arks',NULL,NULL,X'C2881000',X'C2881000');"
1440 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1441 ",-917504,10,'s_ID_13','s_ID"
1442 "_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN | Internet Corpo"
1443 "ration for Assigned Names and Numbers','ICANN | Internet Corporation"
1444 " for Assigned Names and Numbers',NULL,NULL,X'C28810240A15687474703A2"
1445 "F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',X'C288102"
1446 "00A15687474703A2F2F7777772E6963616E6E2E636F6D2F120744414146415346');"
1447 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1448 ",1048576,11,'s_ID_14','s_ID"
1449 "_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Open Source Proje"
1450 "ct','The WebKit Open Source Project',NULL,NULL,X'C288101A0A126874747"
1451 "03A2F2F7765626B69742E6F72672F1204504E4758',X'C288101C0A13687474703A2"
1452 "F2F7765626B69742E6F72672F781205504E473259');"
1453 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1454 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1455 "ult -2, cache_guid TEXT , notification_state BLOB);"
1456 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1457 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"
1458 "9010788312004066376x-6609234393368420856x',NULL);"
1460 ASSERT_TRUE(connection->CommitTransaction());
1463 void MigrationTest::SetUpVersion77Database(sql::Connection* connection) {
1464 ASSERT_TRUE(connection->is_open());
1465 ASSERT_TRUE(connection->BeginTransaction());
1466 ASSERT_TRUE(connection->Execute(
1467 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1468 "INSERT INTO 'share_version' VALUES('nick@chromium.org',77);"
1469 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1470 "itial_sync_ended BOOLEAN default 0);"
1471 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1472 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1473 "_version bigint default -1,server_version bigint default 0,server_po"
1474 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1475 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1476 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1477 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1478 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1479 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1480 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1481 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1482 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1483 "har,specifics blob,server_specifics blob);"
1484 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1)
1485 ",'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'');"
1486 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1487 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1488 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1489 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1490 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1491 "14447414447414447');"
1492 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1493 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1494 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1495 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1496 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1497 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1498 "E2F77656C636F6D652E68746D6C1200');"
1499 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7," META_PROTO_TIMES_VALS(5)
1500 ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','"
1501 "Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E"
1502 "636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E67"
1503 "6F6F676C652E636F6D2F12084147464447415347');"
1504 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1505 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1506 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1507 ");"
1508 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0," META_PROTO_TIMES_VALS(7)
1509 ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Goo"
1510 "gle Chrome','google_chrome',NULL,NULL,NULL);"
1511 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0," META_PROTO_TIMES_VALS(8)
1512 ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmar"
1513 "ks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1514 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1," META_PROTO_TIMES_VALS(9)
1515 ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar'"
1516 ",'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1517 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1518 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1519 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1520 "LL,X'C2881000',X'C2881000');"
1521 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1522 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1523 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1524 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1525 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1526 "8726F6D69756D2E6F72672F6F7468657212084146414756415346');"
1527 "INSERT INTO 'metas' VALUES(12,685,685,0,9," META_PROTO_TIMES_VALS(12)
1528 ",'s_ID_12','s_ID_6','s_"
1529 "ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookm"
1530 "arks',NULL,NULL,X'C2881000',X'C2881000');"
1531 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1532 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1533 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1534 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1535 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1536 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1537 "E6963616E6E2E636F6D2F120744414146415346');"
1538 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1539 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1540 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1541 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1542 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1543 "81205504E473259');"
1544 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1545 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1546 "ult -2, cache_guid TEXT , notification_state BLOB);"
1547 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1548 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"
1549 "9010788312004066376x-6609234393368420856x',NULL);"
1551 ASSERT_TRUE(connection->CommitTransaction());
1554 void MigrationTest::SetUpVersion78Database(sql::Connection* connection) {
1555 ASSERT_TRUE(connection->is_open());
1556 ASSERT_TRUE(connection->BeginTransaction());
1557 ASSERT_TRUE(connection->Execute(
1558 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1559 "INSERT INTO 'share_version' VALUES('nick@chromium.org',78);"
1560 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1561 "itial_sync_ended BOOLEAN default 0);"
1562 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1563 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1564 "_version bigint default -1,server_version bigint default 0,server_po"
1565 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1566 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1567 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1568 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1569 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1570 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1571 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1572 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1573 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1574 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1575 ");"
1576 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1577 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL);"
1578 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1579 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1580 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1581 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1582 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1583 "14447414447414447',NULL);"
1584 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1585 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1586 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1587 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1588 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1589 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1590 "E2F77656C636F6D652E68746D6C1200',NULL);"
1591 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7,"
1592 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1593 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1594 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1595 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1596 "ULL);"
1597 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1598 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1599 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1600 ",NULL);"
1601 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0,"
1602 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1603 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL);"
1604 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0,"
1605 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1606 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1607 "00',X'C2881000',NULL);"
1608 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1,"
1609 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1610 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1611 "000',X'C2881000',NULL);"
1612 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1613 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1614 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1615 "LL,X'C2881000',X'C2881000',NULL);"
1616 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1617 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1618 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1619 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1620 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1621 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL);"
1622 "INSERT INTO 'metas' VALUES(12,685,685,0,9,"
1623 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1624 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1625 "2881000',X'C2881000',NULL);"
1626 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1627 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1628 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1629 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1630 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1631 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1632 "E6963616E6E2E636F6D2F120744414146415346',NULL);"
1633 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1634 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1635 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1636 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1637 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1638 "81205504E473259',NULL);"
1639 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1640 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1641 "ult -2, cache_guid TEXT , notification_state BLOB);"
1642 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1643 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"
1644 "9010788312004066376x-6609234393368420856x',NULL);"
1646 ASSERT_TRUE(connection->CommitTransaction());
1649 void MigrationTest::SetUpVersion79Database(sql::Connection* connection) {
1650 ASSERT_TRUE(connection->is_open());
1651 ASSERT_TRUE(connection->BeginTransaction());
1652 ASSERT_TRUE(connection->Execute(
1653 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1654 "INSERT INTO 'share_version' VALUES('nick@chromium.org',79);"
1655 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1656 "itial_sync_ended BOOLEAN default 0);"
1657 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1658 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1659 "_version bigint default -1,server_version bigint default 0,server_po"
1660 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1661 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1662 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1663 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1664 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1665 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1666 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1667 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1668 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1669 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1670 ");"
1671 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1672 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL);"
1673 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1674 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1675 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1676 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1677 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1678 "14447414447414447',NULL);"
1679 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1680 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1681 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1682 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1683 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1684 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1685 "E2F77656C636F6D652E68746D6C1200',NULL);"
1686 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7,"
1687 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1688 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1689 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1690 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1691 "ULL);"
1692 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1693 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1694 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1695 ",NULL);"
1696 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0,"
1697 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1698 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL);"
1699 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0,"
1700 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1701 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1702 "00',X'C2881000',NULL);"
1703 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1,"
1704 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1705 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1706 "000',X'C2881000',NULL);"
1707 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1708 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1709 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1710 "LL,X'C2881000',X'C2881000',NULL);"
1711 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1712 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1713 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1714 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1715 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1716 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL);"
1717 "INSERT INTO 'metas' VALUES(12,685,685,0,9,"
1718 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1719 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1720 "2881000',X'C2881000',NULL);"
1721 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1722 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1723 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1724 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1725 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1726 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1727 "E6963616E6E2E636F6D2F120744414146415346',NULL);"
1728 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1729 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1730 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1731 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1732 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1733 "81205504E473259',NULL);"
1734 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1735 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1736 "ult -2, cache_guid TEXT , notification_state BLOB);"
1737 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1738 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
1739 "-131078,'9010788312004066376x-6609234393368420856x',NULL);"
1741 ASSERT_TRUE(connection->CommitTransaction());
1744 void MigrationTest::SetUpVersion80Database(sql::Connection* connection) {
1745 ASSERT_TRUE(connection->is_open());
1746 ASSERT_TRUE(connection->BeginTransaction());
1747 ASSERT_TRUE(connection->Execute(
1748 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1749 "INSERT INTO 'share_version' VALUES('nick@chromium.org',80);"
1750 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1751 "itial_sync_ended BOOLEAN default 0);"
1752 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1753 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1754 "_version bigint default -1,server_version bigint default 0,server_po"
1755 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1756 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1757 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1758 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1759 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1760 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1761 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1762 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1763 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1764 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1765 ");"
1766 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1767 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL);"
1768 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1769 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1770 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1771 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1772 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1773 "14447414447414447',NULL);"
1774 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1775 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1776 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1777 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1778 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1779 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1780 "E2F77656C636F6D652E68746D6C1200',NULL);"
1781 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7,"
1782 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1783 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1784 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1785 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1786 "ULL);"
1787 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1788 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1789 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1790 ",NULL);"
1791 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0,"
1792 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1793 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL);"
1794 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0,"
1795 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1796 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1797 "00',X'C2881000',NULL);"
1798 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1,"
1799 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1800 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1801 "000',X'C2881000',NULL);"
1802 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1803 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1804 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1805 "LL,X'C2881000',X'C2881000',NULL);"
1806 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1807 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1808 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1809 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1810 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1811 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL);"
1812 "INSERT INTO 'metas' VALUES(12,685,685,0,9,"
1813 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1814 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1815 "2881000',X'C2881000',NULL);"
1816 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1817 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1818 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1819 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1820 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1821 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1822 "E6963616E6E2E636F6D2F120744414146415346',NULL);"
1823 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1824 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1825 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1826 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1827 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1828 "81205504E473259',NULL);"
1829 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1830 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1831 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
1832 "blob);"
1833 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1834 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
1835 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"
1837 ASSERT_TRUE(connection->CommitTransaction());
1841 // Helper definitions to create the version 81 DB tables.
1842 namespace {
1844 const int V80_ROW_COUNT = 13;
1845 const int64 V80_POSITIONS[V80_ROW_COUNT] = {
1847 -2097152,
1848 -3145728,
1849 1048576,
1850 -4194304,
1851 1048576,
1852 1048576,
1853 1048576,
1854 2097152,
1855 -1048576,
1857 -917504,
1858 1048576
1861 std::string V81_Ordinal(int n) {
1862 return Int64ToNodeOrdinal(V80_POSITIONS[n]).ToInternalValue();
1865 } //namespace
1867 // Unlike the earlier versions, the rows for version 81 are generated
1868 // programmatically to accurately handle unprintable characters for the
1869 // server_ordinal_in_parent field.
1870 void MigrationTest::SetUpVersion81Database(sql::Connection* connection) {
1871 ASSERT_TRUE(connection->is_open());
1872 ASSERT_TRUE(connection->BeginTransaction());
1873 ASSERT_TRUE(connection->Execute(
1874 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1875 "INSERT INTO 'share_version' VALUES('nick@chromium.org',81);"
1876 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1877 "itial_sync_ended BOOLEAN default 0);"
1878 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1879 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1880 "_version bigint default -1,server_version bigint default 0, "
1881 "local_external_id bigint default 0"
1882 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1883 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1884 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1885 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1886 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1887 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1888 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1889 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1890 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1891 ", server_ordinal_in_parent blob);"
1892 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1893 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1894 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
1895 "blob);"
1896 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1897 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
1898 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
1900 const char* insert_stmts[V80_ROW_COUNT] = {
1901 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1902 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?);",
1903 "INSERT INTO 'metas' VALUES(2,669,669,4,"
1904 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1905 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1906 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1907 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1908 "14447414447414447',NULL,?);",
1909 "INSERT INTO 'metas' VALUES(4,681,681,3,"
1910 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1911 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1912 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1913 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1914 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1915 "E2F77656C636F6D652E68746D6C1200',NULL,?);",
1916 "INSERT INTO 'metas' VALUES(5,677,677,7,"
1917 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1918 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1919 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1920 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1921 "ULL,?);",
1922 "INSERT INTO 'metas' VALUES(6,694,694,6,"
1923 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1924 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1925 ",NULL,?);",
1926 "INSERT INTO 'metas' VALUES(7,663,663,0,"
1927 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1928 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?);",
1929 "INSERT INTO 'metas' VALUES(8,664,664,0,"
1930 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1931 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1932 "00',X'C2881000',NULL,?);",
1933 "INSERT INTO 'metas' VALUES(9,665,665,1,"
1934 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1935 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1936 "000',X'C2881000',NULL,?);",
1937 "INSERT INTO 'metas' VALUES(10,666,666,2,"
1938 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1939 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1940 "LL,X'C2881000',X'C2881000',NULL,?);",
1941 "INSERT INTO 'metas' VALUES(11,683,683,8,"
1942 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1943 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1944 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1945 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1946 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?);",
1947 "INSERT INTO 'metas' VALUES(12,685,685,9,"
1948 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1949 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1950 "2881000',X'C2881000',NULL,?);",
1951 "INSERT INTO 'metas' VALUES(13,687,687,10,"
1952 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1953 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1954 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1955 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1956 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1957 "E6963616E6E2E636F6D2F120744414146415346',NULL,?);",
1958 "INSERT INTO 'metas' VALUES(14,692,692,11,"
1959 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1960 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1961 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1962 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1963 "81205504E473259',NULL,?);" };
1965 for (int i = 0; i < V80_ROW_COUNT; i++) {
1966 sql::Statement s(connection->GetUniqueStatement(insert_stmts[i]));
1967 std::string ord = V81_Ordinal(i);
1968 s.BindBlob(0, ord.data(), ord.length());
1969 ASSERT_TRUE(s.Run());
1970 s.Reset(true);
1972 ASSERT_TRUE(connection->CommitTransaction());
1975 void MigrationTest::SetUpVersion82Database(sql::Connection* connection) {
1976 ASSERT_TRUE(connection->is_open());
1977 ASSERT_TRUE(connection->BeginTransaction());
1978 ASSERT_TRUE(connection->Execute(
1979 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1980 "INSERT INTO 'share_version' VALUES('nick@chromium.org',82);"
1981 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1982 "itial_sync_ended BOOLEAN default 0, transaction_version BIGINT "
1983 "default 0);"
1984 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1, 1);"
1985 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1986 "_version bigint default -1,server_version bigint default 0, "
1987 "local_external_id bigint default 0"
1988 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1989 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1990 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1991 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1992 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1993 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1994 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1995 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1996 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1997 ", server_ordinal_in_parent blob);"
1998 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1999 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
2000 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2001 "blob);"
2002 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2003 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2004 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2006 const char* insert_stmts[V80_ROW_COUNT] = {
2007 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2008 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?);",
2009 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2010 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2011 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2012 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2013 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2014 "14447414447414447',NULL,?);",
2015 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2016 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2017 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2018 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2019 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2020 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2021 "E2F77656C636F6D652E68746D6C1200',NULL,?);",
2022 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2023 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2024 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2025 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2026 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2027 "ULL,?);",
2028 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2029 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2030 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2031 ",NULL,?);",
2032 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2033 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2034 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?);",
2035 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2036 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2037 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2038 "00',X'C2881000',NULL,?);",
2039 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2040 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2041 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2042 "000',X'C2881000',NULL,?);",
2043 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2044 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2045 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2046 "LL,X'C2881000',X'C2881000',NULL,?);",
2047 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2048 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2049 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2050 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2051 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2052 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?);",
2053 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2054 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2055 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2056 "2881000',X'C2881000',NULL,?);",
2057 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2058 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2059 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2060 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2061 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2062 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2063 "E6963616E6E2E636F6D2F120744414146415346',NULL,?);",
2064 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2065 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2066 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2067 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2068 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2069 "81205504E473259',NULL,?);" };
2071 for (int i = 0; i < V80_ROW_COUNT; i++) {
2072 sql::Statement s(connection->GetUniqueStatement(insert_stmts[i]));
2073 std::string ord = V81_Ordinal(i);
2074 s.BindBlob(0, ord.data(), ord.length());
2075 ASSERT_TRUE(s.Run());
2076 s.Reset(true);
2078 ASSERT_TRUE(connection->CommitTransaction());
2081 void MigrationTest::SetUpVersion83Database(sql::Connection* connection) {
2082 ASSERT_TRUE(connection->is_open());
2083 ASSERT_TRUE(connection->BeginTransaction());
2084 ASSERT_TRUE(connection->Execute(
2085 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2086 "INSERT INTO 'share_version' VALUES('nick@chromium.org',83);"
2087 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
2088 "itial_sync_ended BOOLEAN default 0, transaction_version BIGINT "
2089 "default 0);"
2090 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1, 1);"
2091 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2092 "_version bigint default -1,server_version bigint default 0, "
2093 "local_external_id bigint default 0"
2094 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2095 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2096 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2097 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2098 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2099 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2100 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2101 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2102 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2103 ", server_ordinal_in_parent blob, transaction_version bigint default "
2104 "0);"
2105 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2106 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
2107 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2108 "blob);"
2109 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2110 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2111 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2113 const char* insert_stmts[V80_ROW_COUNT] = {
2114 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2115 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?,0);",
2116 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2117 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2118 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2119 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2120 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2121 "14447414447414447',NULL,?,0);",
2122 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2123 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2124 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2125 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2126 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2127 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2128 "E2F77656C636F6D652E68746D6C1200',NULL,?,0);",
2129 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2130 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2131 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2132 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2133 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2134 "ULL,?,0);",
2135 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2136 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2137 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2138 ",NULL,?,0);",
2139 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2140 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2141 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?,0);"
2143 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2144 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2145 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2146 "00',X'C2881000',NULL,?,0);",
2147 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2148 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2149 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2150 "000',X'C2881000',NULL,?,0);",
2151 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2152 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2153 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2154 "LL,X'C2881000',X'C2881000',NULL,?,0);",
2155 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2156 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2157 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2158 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2159 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2160 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?,0);",
2161 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2162 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2163 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2164 "2881000',X'C2881000',NULL,?,0);",
2165 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2166 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2167 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2168 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2169 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2170 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2171 "E6963616E6E2E636F6D2F120744414146415346',NULL,?,0);",
2172 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2173 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2174 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2175 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2176 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2177 "81205504E473259',NULL,?,0);" };
2179 for (int i = 0; i < V80_ROW_COUNT; i++) {
2180 sql::Statement s(connection->GetUniqueStatement(insert_stmts[i]));
2181 std::string ord = V81_Ordinal(i);
2182 s.BindBlob(0, ord.data(), ord.length());
2183 ASSERT_TRUE(s.Run());
2184 s.Reset(true);
2186 ASSERT_TRUE(connection->CommitTransaction());
2189 void MigrationTest::SetUpVersion84Database(sql::Connection* connection) {
2190 ASSERT_TRUE(connection->is_open());
2191 ASSERT_TRUE(connection->BeginTransaction());
2192 ASSERT_TRUE(connection->Execute(
2193 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2194 "INSERT INTO 'share_version' VALUES('nick@chromium.org',84);"
2195 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
2196 "itial_sync_ended BOOLEAN default 0, transaction_version BIGINT "
2197 "default 0);"
2198 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1, 1);"
2199 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2200 "_version bigint default -1,server_version bigint default 0, "
2201 "local_external_id bigint default 0"
2202 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2203 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2204 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2205 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2206 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2207 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2208 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2209 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2210 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2211 ", server_ordinal_in_parent blob, transaction_version bigint default "
2212 "0);"
2213 "CREATE TABLE 'deleted_metas'"
2214 "(metahandle bigint primary key ON CONFLICT FAIL,base"
2215 "_version bigint default -1,server_version bigint default 0, "
2216 "local_external_id bigint default 0"
2217 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2218 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2219 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2220 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2221 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2222 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2223 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2224 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2225 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2226 ", server_ordinal_in_parent blob, transaction_version bigint default "
2227 "0);"
2228 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2229 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
2230 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2231 "blob);"
2232 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2233 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2234 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2236 const char* insert_stmts[V80_ROW_COUNT] = {
2237 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2238 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?,0);",
2239 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2240 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2241 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2242 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2243 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2244 "14447414447414447',NULL,?,0);",
2245 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2246 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2247 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2248 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2249 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2250 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2251 "E2F77656C636F6D652E68746D6C1200',NULL,?,0);",
2252 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2253 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2254 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2255 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2256 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2257 "ULL,?,0);",
2258 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2259 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2260 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2261 ",NULL,?,0);",
2262 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2263 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2264 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?,0);"
2266 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2267 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2268 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2269 "00',X'C2881000',NULL,?,0);",
2270 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2271 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2272 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2273 "000',X'C2881000',NULL,?,0);",
2274 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2275 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2276 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2277 "LL,X'C2881000',X'C2881000',NULL,?,0);",
2278 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2279 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2280 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2281 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2282 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2283 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?,0);",
2284 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2285 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2286 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2287 "2881000',X'C2881000',NULL,?,0);",
2288 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2289 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2290 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2291 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2292 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2293 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2294 "E6963616E6E2E636F6D2F120744414146415346',NULL,?,0);",
2295 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2296 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2297 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2298 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2299 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2300 "81205504E473259',NULL,?,0);" };
2302 for (int i = 0; i < V80_ROW_COUNT; i++) {
2303 sql::Statement s(connection->GetUniqueStatement(insert_stmts[i]));
2304 std::string ord = V81_Ordinal(i);
2305 s.BindBlob(0, ord.data(), ord.length());
2306 ASSERT_TRUE(s.Run());
2307 s.Reset(true);
2309 ASSERT_TRUE(connection->CommitTransaction());
2312 void MigrationTest::SetUpVersion85Database(sql::Connection* connection) {
2313 ASSERT_TRUE(connection->is_open());
2314 ASSERT_TRUE(connection->BeginTransaction());
2315 ASSERT_TRUE(connection->Execute(
2316 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2317 "INSERT INTO 'share_version' VALUES('nick@chromium.org',85);"
2318 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, "
2319 "transaction_version BIGINT default 0);"
2320 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605', 1);"
2321 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2322 "_version bigint default -1,server_version bigint default 0, "
2323 "local_external_id bigint default 0"
2324 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2325 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2326 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2327 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2328 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2329 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2330 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2331 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2332 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2333 ", server_ordinal_in_parent blob, transaction_version bigint default "
2334 "0);"
2335 "CREATE TABLE 'deleted_metas'"
2336 "(metahandle bigint primary key ON CONFLICT FAIL,base"
2337 "_version bigint default -1,server_version bigint default 0, "
2338 "local_external_id bigint default 0"
2339 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2340 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2341 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2342 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2343 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2344 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2345 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2346 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2347 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2348 ", server_ordinal_in_parent blob, transaction_version bigint default "
2349 "0);"
2350 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2351 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
2352 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2353 "blob);"
2354 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2355 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2356 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2358 const char* insert_stmts[V80_ROW_COUNT] = {
2359 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2360 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?,0);",
2361 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2362 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2363 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2364 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2365 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2366 "14447414447414447',NULL,?,0);",
2367 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2368 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2369 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2370 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2371 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2372 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2373 "E2F77656C636F6D652E68746D6C1200',NULL,?,0);",
2374 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2375 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2376 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2377 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2378 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2379 "ULL,?,0);",
2380 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2381 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2382 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2383 ",NULL,?,0);",
2384 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2385 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2386 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?,0);"
2388 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2389 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2390 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2391 "00',X'C2881000',NULL,?,0);",
2392 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2393 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2394 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2395 "000',X'C2881000',NULL,?,0);",
2396 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2397 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2398 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2399 "LL,X'C2881000',X'C2881000',NULL,?,0);",
2400 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2401 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2402 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2403 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2404 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2405 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?,0);",
2406 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2407 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2408 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2409 "2881000',X'C2881000',NULL,?,0);",
2410 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2411 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2412 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2413 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2414 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2415 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2416 "E6963616E6E2E636F6D2F120744414146415346',NULL,?,0);",
2417 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2418 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2419 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2420 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2421 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2422 "81205504E473259',NULL,?,0);" };
2424 for (int i = 0; i < V80_ROW_COUNT; i++) {
2425 sql::Statement s(connection->GetUniqueStatement(insert_stmts[i]));
2426 std::string ord = V81_Ordinal(i);
2427 s.BindBlob(0, ord.data(), ord.length());
2428 ASSERT_TRUE(s.Run());
2429 s.Reset(true);
2431 ASSERT_TRUE(connection->CommitTransaction());
2434 void MigrationTest::SetUpVersion86Database(sql::Connection* connection) {
2435 ASSERT_TRUE(connection->is_open());
2436 ASSERT_TRUE(connection->BeginTransaction());
2437 ASSERT_TRUE(connection->Execute(
2438 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2439 "INSERT INTO 'share_version' VALUES('nick@chromium.org',86);"
2440 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB,"
2441 " transaction_version BIGINT default 0);"
2442 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
2443 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,b"
2444 "ase_version bigint default -1,server_version bigint default 0,local_e"
2445 "xternal_id bigint default 0,transaction_version bigint default 0,mtim"
2446 "e bigint default 0,server_mtime bigint default 0,ctime bigint default"
2447 " 0,server_ctime bigint default 0,id varchar(255) default 'r',parent_i"
2448 "d varchar(255) default 'r',server_parent_id varchar(255) default 'r',"
2449 "is_unsynced bit default 0,is_unapplied_update bit default 0,is_del bi"
2450 "t default 0,is_dir bit default 0,server_is_dir bit default 0,server_i"
2451 "s_del bit default 0,non_unique_name varchar,server_non_unique_name va"
2452 "rchar(255),unique_server_tag varchar,unique_client_tag varchar,unique"
2453 "_bookmark_tag varchar,specifics blob,server_specifics blob,base_serve"
2454 "r_specifics blob,server_unique_position blob,unique_position blob);"
2455 "INSERT INTO 'metas' VALUES(1,-1,0,0,0,"
2456 META_PROTO_TIMES_VALS(1)
2457 ",'r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,"
2458 "X'',X'',X'',NULL,X'2200',X'2200');"
2459 "INSERT INTO 'metas' VALUES(6,694,694,6,0,"
2460 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9',0,0,0,1,1,0,'The"
2461 " Internet','The Internet',NULL,NULL,X'6754307476346749735A5734654D653"
2462 "273625336557753582F77673D',X'C2881000',X'C2881000',NULL,X'22247FFFFFF"
2463 "FFFC000006754307476346749735A5734654D653273625336557753582F77673D',X'"
2464 "22247FFFFFFFFFC000006754307476346749735A5734654D653273625336557753582"
2465 "F77673D');"
2466 "INSERT INTO 'metas' VALUES(7,663,663,0,0,"
2467 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r',0,0,0,1,1,0,'Google Chrome"
2468 "','Google Chrome','google_chrome',NULL,X'',NULL,NULL,NULL,X'2200',X'2"
2469 "200');"
2470 "INSERT INTO 'metas' VALUES(8,664,664,0,0,"
2471 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7',0,0,0,1,1,0,'Boo"
2472 "kmarks','Bookmarks','google_chrome_bookmarks',NULL,X'',X'C2881000',X'"
2473 "C2881000',NULL,X'2200',X'2200');"
2474 "INSERT INTO 'metas' VALUES(9,665,665,1,0,"
2475 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8',0,0,0,1,1,0,'Boo"
2476 "kmark Bar','Bookmark Bar','bookmark_bar',NULL,X'',X'C2881000',X'C2881"
2477 "000',NULL,X'2200',X'2200');"
2478 "INSERT INTO 'metas' VALUES(10,666,666,2,0,"
2479 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8',0,0,0,1,1,0,'O"
2480 "ther Bookmarks','Other Bookmarks','other_bookmarks',NULL,X'',X'C28810"
2481 "00',X'C2881000',NULL,X'2200',X'2200');"
2482 "INSERT INTO 'metas' VALUES(11,683,683,8,0,"
2483 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6',0,0,0,0,0,0,'H"
2484 "ome (The Chromium Projects)','Home (The Chromium Projects)',NULL,NULL"
2485 ",X'50514C784A456D623579366267644237646A7A2B62314130346E493D',X'C28810"
2486 "220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F120641474154574"
2487 "1',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74"
2488 "68657212084146414756415346',NULL,X'22247FFFFFFFFFF0000050514C784A456D"
2489 "623579366267644237646A7A2B62314130346E493D',X'22247FFFFFFFFFF00000505"
2490 "14C784A456D623579366267644237646A7A2B62314130346E493D');"
2491 "INSERT INTO 'metas' VALUES(12,685,685,9,0,"
2492 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6',0,0,0,1,1,0,'E"
2493 "xtra Bookmarks','Extra Bookmarks',NULL,NULL,X'7867626A704A646134635A6"
2494 "F616C376A49513338734B46324837773D',X'C2881000',X'C2881000',NULL,X'222"
2495 "480000000000000007867626A704A646134635A6F616C376A49513338734B46324837"
2496 "773D',X'222480000000000000007867626A704A646134635A6F616C376A495133387"
2497 "34B46324837773D');"
2498 "INSERT INTO 'metas' VALUES(13,687,687,10,0,"
2499 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6',0,0,0,0,0,0,'I"
2500 "CANN | Internet Corporation for Assigned Names and Numbers','ICANN | "
2501 "Internet Corporation for Assigned Names and Numbers',NULL,NULL,X'3142"
2502 "756B572F7741766956504179672B304A614A514B3452384A413D',X'C28810240A156"
2503 "87474703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',"
2504 "X'C28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F1207444141464"
2505 "15346',NULL,X'22247FFFFFFFFFF200003142756B572F7741766956504179672B304"
2506 "A614A514B3452384A413D',X'22247FFFFFFFFFF200003142756B572F774176695650"
2507 "4179672B304A614A514B3452384A413D');"
2508 "INSERT INTO 'metas' VALUES(14,692,692,11,0,"
2509 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6',0,0,0,0,0,0,'T"
2510 "he WebKit Open Source Project','The WebKit Open Source Project',NULL,"
2511 "NULL,X'5A5678314E7976364579524D3177494F7236563159552F6E644C553D',X'C2"
2512 "88101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101"
2513 "C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259',NULL,X'222"
2514 "480000000001000005A5678314E7976364579524D3177494F7236563159552F6E644C"
2515 "553D',X'222480000000001000005A5678314E7976364579524D3177494F723656315"
2516 "9552F6E644C553D');"
2517 "CREATE TABLE deleted_metas (metahandle bigint primary key ON CONFLICT FA"
2518 "IL,base_version bigint default -1,server_version bigint default 0,loc"
2519 "al_external_id bigint default 0,transaction_version bigint default 0,"
2520 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint def"
2521 "ault 0,server_ctime bigint default 0,id varchar(255) default 'r',pare"
2522 "nt_id varchar(255) default 'r',server_parent_id varchar(255) default "
2523 "'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is_de"
2524 "l bit default 0,is_dir bit default 0,server_is_dir bit default 0,serv"
2525 "er_is_del bit default 0,non_unique_name varchar,server_non_unique_nam"
2526 "e varchar(255),unique_server_tag varchar,unique_client_tag varchar,un"
2527 "ique_bookmark_tag varchar,specifics blob,server_specifics blob,base_s"
2528 "erver_specifics blob,server_unique_position blob,unique_position blob"
2529 ");"
2530 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birt"
2531 "hday TEXT, db_create_version TEXT, db_create_time INT, next_id INT de"
2532 "fault -2, cache_guid TEXT, notification_state BLOB, bag_of_chips BLOB"
2533 ");"
2534 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.or"
2535 "g','c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-13107"
2536 "8,'9010788312004066376x-6609234393368420856x',NULL,NULL);"));
2537 ASSERT_TRUE(connection->CommitTransaction());
2540 void MigrationTest::SetUpVersion87Database(sql::Connection* connection) {
2541 ASSERT_TRUE(connection->is_open());
2542 ASSERT_TRUE(connection->BeginTransaction());
2543 ASSERT_TRUE(connection->Execute(
2544 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2545 "INSERT INTO 'share_version' VALUES('nick@chromium.org',87);"
2546 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, tr"
2547 "ansaction_version BIGINT default 0);"
2548 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
2549 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2550 "_version bigint default -1,server_version bigint default 0,local_exte"
2551 "rnal_id bigint default 0,transaction_version bigint default 0,mtime b"
2552 "igint default 0,server_mtime bigint default 0,ctime bigint default 0,"
2553 "server_ctime bigint default 0,id varchar(255) default 'r',parent_id v"
2554 "archar(255) default 'r',server_parent_id varchar(255) default 'r',is_"
2555 "unsynced bit default 0,is_unapplied_update bit default 0,is_del bit d"
2556 "efault 0,is_dir bit default 0,server_is_dir bit default 0,server_is_d"
2557 "el bit default 0,non_unique_name varchar,server_non_unique_name varch"
2558 "ar(255),unique_server_tag varchar,unique_client_tag varchar,unique_bo"
2559 "okmark_tag varchar,specifics blob,server_specifics blob,base_server_s"
2560 "pecifics blob,server_unique_position blob,unique_position blob,attach"
2561 "ment_metadata blob);"
2562 "INSERT INTO 'metas' VALUES(1,-1,0,0,0,"
2563 META_PROTO_TIMES_VALS(1)
2564 ",'r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X''"
2565 ",X'',X'',NULL,X'2200',X'2200',NULL);"
2566 "INSERT INTO 'metas' VALUES(6,694,694,6,0,"
2567 META_PROTO_TIMES_VALS(6)
2568 ",'s_ID_6','s_ID_9','s_ID_9',0,0,0,1,1,0,'The "
2569 "Internet','The Internet',NULL,NULL,X'6754307476346749735A5734654D6532"
2570 "73625336557753582F77673D',X'C2881000',X'C2881000',NULL,X'22247FFFFFFF"
2571 "FFC000006754307476346749735A5734654D653273625336557753582F77673D',X'2"
2572 "2247FFFFFFFFFC000006754307476346749735A5734654D653273625336557753582F"
2573 "77673D',NULL);"
2574 "INSERT INTO 'metas' VALUES(7,663,663,0,0,"
2575 META_PROTO_TIMES_VALS(7)
2576 ",'s_ID_7','r','r',0,0,0,1,1,0,'Google Chrome'"
2577 ",'Google Chrome','google_chrome',NULL,X'',NULL,NULL,NULL,X'2200',X'22"
2578 "00',NULL);"
2579 "INSERT INTO 'metas' VALUES(8,664,664,0,0,"
2580 META_PROTO_TIMES_VALS(8)
2581 ",'s_ID_8','s_ID_7','s_ID_7',0,0,0,1,1,0,'Book"
2582 "marks','Bookmarks','google_chrome_bookmarks',NULL,X'',X'C2881000',X'C"
2583 "2881000',NULL,X'2200',X'2200',NULL);"
2584 "INSERT INTO 'metas' VALUES(9,665,665,1,0,"
2585 META_PROTO_TIMES_VALS(9)
2586 ",'s_ID_9','s_ID_8','s_ID_8',0,0,0,1,1,0,'Book"
2587 "mark Bar','Bookmark Bar','bookmark_bar',NULL,X'',X'C2881000',X'C28810"
2588 "00',NULL,X'2200',X'2200',NULL);"
2589 "INSERT INTO 'metas' VALUES(10,666,666,2,0,"
2590 META_PROTO_TIMES_VALS(10)
2591 ",'s_ID_10','s_ID_8','s_ID_8',0,0,0,1,1,0,'Ot"
2592 "her Bookmarks','Other Bookmarks','other_bookmarks',NULL,X'',X'C288100"
2593 "0',X'C2881000',NULL,X'2200',X'2200',NULL);"
2594 "INSERT INTO 'metas' VALUES(11,683,683,8,0,"
2595 META_PROTO_TIMES_VALS(11)
2596 ",'s_ID_11','s_ID_6','s_ID_6',0,0,0,0,0,0,'Ho"
2597 "me (The Chromium Projects)','Home (The Chromium Projects)',NULL,NULL,"
2598 "X'50514C784A456D623579366267644237646A7A2B62314130346E493D',X'C288102"
2599 "20A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741"
2600 "',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F746"
2601 "8657212084146414756415346',NULL,X'22247FFFFFFFFFF0000050514C784A456D6"
2602 "23579366267644237646A7A2B62314130346E493D',X'22247FFFFFFFFFF000005051"
2603 "4C784A456D623579366267644237646A7A2B62314130346E493D',NULL);"
2604 "INSERT INTO 'metas' VALUES(12,685,685,9,0,"
2605 META_PROTO_TIMES_VALS(12)
2606 ",'s_ID_12','s_ID_6','s_ID_6',0,0,0,1,1,0,'Ex"
2607 "tra Bookmarks','Extra Bookmarks',NULL,NULL,X'7867626A704A646134635A6F"
2608 "616C376A49513338734B46324837773D',X'C2881000',X'C2881000',NULL,X'2224"
2609 "80000000000000007867626A704A646134635A6F616C376A49513338734B463248377"
2610 "73D',X'222480000000000000007867626A704A646134635A6F616C376A4951333873"
2611 "4B46324837773D',NULL);"
2612 "INSERT INTO 'metas' VALUES(13,687,687,10,0,"
2613 META_PROTO_TIMES_VALS(13)
2614 ",'s_ID_13','s_ID_6','s_ID_6',0,0,0,0,0,0,'I"
2615 "CANN | Internet Corporation for Assigned Names and Numbers','ICANN | "
2616 "Internet Corporation for Assigned Names and Numbers',NULL,NULL,X'3142"
2617 "756B572F7741766956504179672B304A614A514B3452384A413D',X'C28810240A156"
2618 "87474703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',"
2619 "X'C28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F1207444141464"
2620 "15346',NULL,X'22247FFFFFFFFFF200003142756B572F7741766956504179672B304"
2621 "A614A514B3452384A413D',X'22247FFFFFFFFFF200003142756B572F774176695650"
2622 "4179672B304A614A514B3452384A413D',NULL);"
2623 "INSERT INTO 'metas' VALUES(14,692,692,11,0,"
2624 META_PROTO_TIMES_VALS(14)
2625 ",'s_ID_14','s_ID_6','s_ID_6',0,0,0,0,0,0,'T"
2626 "he WebKit Open Source Project','The WebKit Open Source Project',NULL,"
2627 "NULL,X'5A5678314E7976364579524D3177494F7236563159552F6E644C553D',X'C2"
2628 "88101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101"
2629 "C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259',NULL,X'222"
2630 "480000000001000005A5678314E7976364579524D3177494F7236563159552F6E644C"
2631 "553D',X'222480000000001000005A5678314E7976364579524D3177494F723656315"
2632 "9552F6E644C553D',NULL);"
2633 "CREATE TABLE deleted_metas (metahandle bigint primary key ON CONFLICT FA"
2634 "IL,base_version bigint default -1,server_version bigint default 0,loc"
2635 "al_external_id bigint default 0,transaction_version bigint default 0,"
2636 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint def"
2637 "ault 0,server_ctime bigint default 0,id varchar(255) default 'r',pare"
2638 "nt_id varchar(255) default 'r',server_parent_id varchar(255) default "
2639 "'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is_de"
2640 "l bit default 0,is_dir bit default 0,server_is_dir bit default 0,serv"
2641 "er_is_del bit default 0,non_unique_name varchar,server_non_unique_nam"
2642 "e varchar(255),unique_server_tag varchar,unique_client_tag varchar,un"
2643 "ique_bookmark_tag varchar,specifics blob,server_specifics blob,base_s"
2644 "erver_specifics blob,server_unique_position blob,unique_position blob"
2645 ",attachment_metadata blob);"
2646 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2647 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defau"
2648 "lt -2, cache_guid TEXT, notification_state BLOB, bag_of_chips BLOB);"
2649 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2650 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-131078,'"
2651 "9010788312004066376x-6609234393368420856x',NULL,NULL);"));
2652 ASSERT_TRUE(connection->CommitTransaction());
2655 void MigrationTest::SetUpVersion88Database(sql::Connection* connection) {
2656 ASSERT_TRUE(connection->is_open());
2657 ASSERT_TRUE(connection->BeginTransaction());
2658 ASSERT_TRUE(connection->Execute(
2659 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2660 "INSERT INTO 'share_version' VALUES('nick@chromium.org',88);"
2661 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB,"
2662 " transaction_version BIGINT default 0, context BLOB);"
2663 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1,NULL);"
2664 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2665 "_version bigint default -1,server_version bigint default 0,local_exte"
2666 "rnal_id bigint default 0,transaction_version bigint default 0,mtime b"
2667 "igint default 0,server_mtime bigint default 0,ctime bigint default 0,"
2668 "server_ctime bigint default 0,id varchar(255) default 'r',parent_id v"
2669 "archar(255) default 'r',server_parent_id varchar(255) default 'r',is_"
2670 "unsynced bit default 0,is_unapplied_update bit default 0,is_del bit d"
2671 "efault 0,is_dir bit default 0,server_is_dir bit default 0,server_is_d"
2672 "el bit default 0,non_unique_name varchar,server_non_unique_name varch"
2673 "ar(255),unique_server_tag varchar,unique_client_tag varchar,unique_bo"
2674 "okmark_tag varchar,specifics blob,server_specifics blob,base_server_s"
2675 "pecifics blob,server_unique_position blob,unique_position blob,attach"
2676 "ment_metadata blob);"
2677 "INSERT INTO 'metas' VALUES(1,-1,0,0,0,"
2678 META_PROTO_TIMES_VALS(1)
2679 ",'r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X''"
2680 ",X'',X'',NULL,X'2200',X'2200',NULL);"
2681 "INSERT INTO 'metas' VALUES(6,694,694,6,0,"
2682 META_PROTO_TIMES_VALS(6)
2683 ",'s_ID_6','s_ID_9','s_ID_9',0,0,0,1,1,0,'The "
2684 "Internet','The Internet',NULL,NULL,X'6754307476346749735A5734654D6532"
2685 "73625336557753582F77673D',X'C2881000',X'C2881000',NULL,X'22247FFFFFFF"
2686 "FFC000006754307476346749735A5734654D653273625336557753582F77673D',X'2"
2687 "2247FFFFFFFFFC000006754307476346749735A5734654D653273625336557753582F"
2688 "77673D',NULL);"
2689 "INSERT INTO 'metas' VALUES(7,663,663,0,0,"
2690 META_PROTO_TIMES_VALS(7)
2691 ",'s_ID_7','r','r',0,0,0,1,1,0,'Google Chrome'"
2692 ",'Google Chrome','google_chrome',NULL,X'',NULL,NULL,NULL,X'2200',X'22"
2693 "00',NULL);"
2694 "INSERT INTO 'metas' VALUES(8,664,664,0,0,"
2695 META_PROTO_TIMES_VALS(8)
2696 ",'s_ID_8','s_ID_7','s_ID_7',0,0,0,1,1,0,'Book"
2697 "marks','Bookmarks','google_chrome_bookmarks',NULL,X'',X'C2881000',X'C"
2698 "2881000',NULL,X'2200',X'2200',NULL);"
2699 "INSERT INTO 'metas' VALUES(9,665,665,1,0,"
2700 META_PROTO_TIMES_VALS(9)
2701 ",'s_ID_9','s_ID_8','s_ID_8',0,0,0,1,1,0,'Book"
2702 "mark Bar','Bookmark Bar','bookmark_bar',NULL,X'',X'C2881000',X'C28810"
2703 "00',NULL,X'2200',X'2200',NULL);"
2704 "INSERT INTO 'metas' VALUES(10,666,666,2,0,"
2705 META_PROTO_TIMES_VALS(10)
2706 ",'s_ID_10','s_ID_8','s_ID_8',0,0,0,1,1,0,'Ot"
2707 "her Bookmarks','Other Bookmarks','other_bookmarks',NULL,X'',X'C288100"
2708 "0',X'C2881000',NULL,X'2200',X'2200',NULL);"
2709 "INSERT INTO 'metas' VALUES(11,683,683,8,0,"
2710 META_PROTO_TIMES_VALS(11)
2711 ",'s_ID_11','s_ID_6','s_ID_6',0,0,0,0,0,0,'Ho"
2712 "me (The Chromium Projects)','Home (The Chromium Projects)',NULL,NULL,"
2713 "X'50514C784A456D623579366267644237646A7A2B62314130346E493D',X'C288102"
2714 "20A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741"
2715 "',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F746"
2716 "8657212084146414756415346',NULL,X'22247FFFFFFFFFF0000050514C784A456D6"
2717 "23579366267644237646A7A2B62314130346E493D',X'22247FFFFFFFFFF000005051"
2718 "4C784A456D623579366267644237646A7A2B62314130346E493D',NULL);"
2719 "INSERT INTO 'metas' VALUES(12,685,685,9,0,"
2720 META_PROTO_TIMES_VALS(12)
2721 ",'s_ID_12','s_ID_6','s_ID_6',0,0,0,1,1,0,'Ex"
2722 "tra Bookmarks','Extra Bookmarks',NULL,NULL,X'7867626A704A646134635A6F"
2723 "616C376A49513338734B46324837773D',X'C2881000',X'C2881000',NULL,X'2224"
2724 "80000000000000007867626A704A646134635A6F616C376A49513338734B463248377"
2725 "73D',X'222480000000000000007867626A704A646134635A6F616C376A4951333873"
2726 "4B46324837773D',NULL);"
2727 "INSERT INTO 'metas' VALUES(13,687,687,10,0,"
2728 META_PROTO_TIMES_VALS(13)
2729 ",'s_ID_13','s_ID_6','s_ID_6',0,0,0,0,0,0,'I"
2730 "CANN | Internet Corporation for Assigned Names and Numbers','ICANN | "
2731 "Internet Corporation for Assigned Names and Numbers',NULL,NULL,X'3142"
2732 "756B572F7741766956504179672B304A614A514B3452384A413D',X'C28810240A156"
2733 "87474703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',"
2734 "X'C28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F1207444141464"
2735 "15346',NULL,X'22247FFFFFFFFFF200003142756B572F7741766956504179672B304"
2736 "A614A514B3452384A413D',X'22247FFFFFFFFFF200003142756B572F774176695650"
2737 "4179672B304A614A514B3452384A413D',NULL);"
2738 "INSERT INTO 'metas' VALUES(14,692,692,11,0,"
2739 META_PROTO_TIMES_VALS(14)
2740 ",'s_ID_14','s_ID_6','s_ID_6',0,0,0,0,0,0,'T"
2741 "he WebKit Open Source Project','The WebKit Open Source Project',NULL,"
2742 "NULL,X'5A5678314E7976364579524D3177494F7236563159552F6E644C553D',X'C2"
2743 "88101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101"
2744 "C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259',NULL,X'222"
2745 "480000000001000005A5678314E7976364579524D3177494F7236563159552F6E644C"
2746 "553D',X'222480000000001000005A5678314E7976364579524D3177494F723656315"
2747 "9552F6E644C553D',NULL);"
2748 "CREATE TABLE deleted_metas (metahandle bigint primary key ON CONFLICT FA"
2749 "IL,base_version bigint default -1,server_version bigint default 0,loc"
2750 "al_external_id bigint default 0,transaction_version bigint default 0,"
2751 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint def"
2752 "ault 0,server_ctime bigint default 0,id varchar(255) default 'r',pare"
2753 "nt_id varchar(255) default 'r',server_parent_id varchar(255) default "
2754 "'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is_de"
2755 "l bit default 0,is_dir bit default 0,server_is_dir bit default 0,serv"
2756 "er_is_del bit default 0,non_unique_name varchar,server_non_unique_nam"
2757 "e varchar(255),unique_server_tag varchar,unique_client_tag varchar,un"
2758 "ique_bookmark_tag varchar,specifics blob,server_specifics blob,base_s"
2759 "erver_specifics blob,server_unique_position blob,unique_position blob"
2760 ",attachment_metadata blob);"
2761 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2762 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defau"
2763 "lt -2, cache_guid TEXT, notification_state BLOB, bag_of_chips BLOB);"
2764 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2765 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-131078,'"
2766 "9010788312004066376x-6609234393368420856x',NULL,NULL);"));
2767 ASSERT_TRUE(connection->CommitTransaction());
2771 void MigrationTest::SetUpVersion89Database(sql::Connection* connection) {
2772 ASSERT_TRUE(connection->is_open());
2773 ASSERT_TRUE(connection->BeginTransaction());
2774 ASSERT_TRUE(connection->Execute(
2775 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2776 "INSERT INTO 'share_version' VALUES('nick@chromium.org',89);"
2777 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, tr"
2778 "ansaction_version BIGINT default 0, context BLOB);"
2779 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1,NULL);"
2780 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2781 "_version bigint default -1,server_version bigint default 0,local_exte"
2782 "rnal_id bigint default 0,transaction_version bigint default 0,mtime b"
2783 "igint default 0,server_mtime bigint default 0,ctime bigint default 0,"
2784 "server_ctime bigint default 0,id varchar(255) default 'r',parent_id v"
2785 "archar(255) default 'r',server_parent_id varchar(255) default 'r',is_"
2786 "unsynced bit default 0,is_unapplied_update bit default 0,is_del bit d"
2787 "efault 0,is_dir bit default 0,server_is_dir bit default 0,server_is_d"
2788 "el bit default 0,non_unique_name varchar,server_non_unique_name varch"
2789 "ar(255),unique_server_tag varchar,unique_client_tag varchar,unique_bo"
2790 "okmark_tag varchar,specifics blob,server_specifics blob,base_server_s"
2791 "pecifics blob,server_unique_position blob,unique_position blob,attach"
2792 "ment_metadata blob,server_attachment_metadata blob);"
2793 "INSERT INTO 'metas' VALUES(1,-1,0,0,0,"
2794 META_PROTO_TIMES_VALS(1)
2795 ",'r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',X'',NULL,X'2200'"
2796 ",X'2200',NULL,NULL);"
2797 "INSERT INTO 'metas' VALUES(6,694,694,6,0,"
2798 META_PROTO_TIMES_VALS(6)
2799 ",'s_ID_6','s_ID_9','s_ID_9',0,0,0,1,1,0,'The Internet','The Internet'"
2800 ",NULL,NULL,X'6754307476346749735A5734654D653273625336557753582F77673D"
2801 "',X'C2881000',X'C2881000',NULL,X'22247FFFFFFFFFC000006754307476346749"
2802 "735A5734654D653273625336557753582F77673D',X'22247FFFFFFFFFC0000067543"
2803 "07476346749735A5734654D653273625336557753582F77673D',NULL,NULL);"
2804 "INSERT INTO 'metas' VALUES(7,663,663,0,0,"
2805 META_PROTO_TIMES_VALS(7)
2806 ",'s_ID_7','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google"
2807 "_chrome',NULL,X'',NULL,NULL,NULL,X'2200',X'2200',NULL,NULL);"
2808 "INSERT INTO 'metas' VALUES(8,664,664,0,0,"
2809 META_PROTO_TIMES_VALS(8)
2810 ",'s_ID_8','s_ID_7','s_ID_7',0,0,0,1,1,0,'Bookmarks','Bookmarks','goog"
2811 "le_chrome_bookmarks',NULL,X'',X'C2881000',X'C2881000',NULL,X'2200',X'"
2812 "2200',NULL,NULL);"
2813 "INSERT INTO 'metas' VALUES(9,665,665,1,0,"
2814 META_PROTO_TIMES_VALS(9)
2815 ",'s_ID_9','s_ID_8','s_ID_8',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar'"
2816 ",'bookmark_bar',NULL,X'',X'C2881000',X'C2881000',NULL,X'2200',X'2200'"
2817 ",NULL,NULL);"
2818 "INSERT INTO 'metas' VALUES(10,666,666,2,0,"
2819 META_PROTO_TIMES_VALS(10)
2820 ",'s_ID_10','s_ID_8','s_ID_8',0,0,0,1,1,0,'Other Bookmarks','Other Boo"
2821 "kmarks','other_bookmarks',NULL,X'',X'C2881000',X'C2881000',NULL,X'220"
2822 "0',X'2200',NULL,NULL);"
2823 "INSERT INTO 'metas' VALUES(11,683,683,8,0,"
2824 META_PROTO_TIMES_VALS(11)
2825 ",'s_ID_11','s_ID_6','s_ID_6',0,0,0,0,0,0,'Home (The Chromium Projects"
2826 ")','Home (The Chromium Projects)',NULL,NULL,X'50514C784A456D623579366"
2827 "267644237646A7A2B62314130346E493D',X'C28810220A18687474703A2F2F646576"
2828 "2E6368726F6D69756D2E6F72672F1206414741545741',X'C28810290A1D687474703"
2829 "A2F2F6465762E6368726F6D69756D2E6F72672F6F7468657212084146414756415346"
2830 "',NULL,X'22247FFFFFFFFFF0000050514C784A456D623579366267644237646A7A2B"
2831 "62314130346E493D',X'22247FFFFFFFFFF0000050514C784A456D623579366267644"
2832 "237646A7A2B62314130346E493D',NULL,NULL);"
2833 "INSERT INTO 'metas' VALUES(12,685,685,9,0,"
2834 META_PROTO_TIMES_VALS(12)
2835 ",'s_ID_12','s_ID_6','s_ID_6',0,0,0,1,1,0,'Extra Bookmarks','Extra Boo"
2836 "kmarks',NULL,NULL,X'7867626A704A646134635A6F616C376A49513338734B46324"
2837 "837773D',X'C2881000',X'C2881000',NULL,X'222480000000000000007867626A7"
2838 "04A646134635A6F616C376A49513338734B46324837773D',X'222480000000000000"
2839 "007867626A704A646134635A6F616C376A49513338734B46324837773D',NULL,NULL"
2840 ");"
2841 "INSERT INTO 'metas' VALUES(13,687,687,10,0,"
2842 META_PROTO_TIMES_VALS(13)
2843 ",'s_ID_13','s_ID_6','s_ID_6',0,0,0,0,0,0,'ICANN | Internet Corporatio"
2844 "n for Assigned Names and Numbers','ICANN | Internet Corporation for A"
2845 "ssigned Names and Numbers',NULL,NULL,X'3142756B572F774176695650417967"
2846 "2B304A614A514B3452384A413D',X'C28810240A15687474703A2F2F7777772E69636"
2847 "16E6E2E636F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F"
2848 "2F7777772E6963616E6E2E636F6D2F120744414146415346',NULL,X'22247FFFFFFF"
2849 "FFF200003142756B572F7741766956504179672B304A614A514B3452384A413D',X'2"
2850 "2247FFFFFFFFFF200003142756B572F7741766956504179672B304A614A514B345238"
2851 "4A413D',NULL,NULL);"
2852 "INSERT INTO 'metas' VALUES(14,692,692,11,0,"
2853 META_PROTO_TIMES_VALS(14)
2854 ",'s_ID_14','s_ID_6','s_ID_6',0,0,0,0,0,0,'The WebKit Open Source Proj"
2855 "ect','The WebKit Open Source Project',NULL,NULL,X'5A5678314E797636457"
2856 "9524D3177494F7236563159552F6E644C553D',X'C288101A0A12687474703A2F2F77"
2857 "65626B69742E6F72672F1204504E4758',X'C288101C0A13687474703A2F2F7765626"
2858 "B69742E6F72672F781205504E473259',NULL,X'222480000000001000005A5678314"
2859 "E7976364579524D3177494F7236563159552F6E644C553D',X'222480000000001000"
2860 "005A5678314E7976364579524D3177494F7236563159552F6E644C553D',NULL,NULL"
2861 ");"
2862 "CREATE TABLE deleted_metas (metahandle bigint primary key ON CONFLICT FA"
2863 "IL,base_version bigint default -1,server_version bigint default 0,loc"
2864 "al_external_id bigint default 0,transaction_version bigint default 0,"
2865 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint def"
2866 "ault 0,server_ctime bigint default 0,id varchar(255) default 'r',pare"
2867 "nt_id varchar(255) default 'r',server_parent_id varchar(255) default "
2868 "'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is_de"
2869 "l bit default 0,is_dir bit default 0,server_is_dir bit default 0,serv"
2870 "er_is_del bit default 0,non_unique_name varchar,server_non_unique_nam"
2871 "e varchar(255),unique_server_tag varchar,unique_client_tag varchar,un"
2872 "ique_bookmark_tag varchar,specifics blob,server_specifics blob,base_s"
2873 "erver_specifics blob,server_unique_position blob,unique_position blob"
2874 ",attachment_metadata blob,server_attachment_metadata blob);"
2875 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2876 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defau"
2877 "lt -2, cache_guid TEXT, notification_state BLOB, bag_of_chips BLOB);"
2878 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2879 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-131078,'"
2880 "9010788312004066376x-6609234393368420856x',NULL,NULL);"));
2881 ASSERT_TRUE(connection->CommitTransaction());
2885 TEST_F(DirectoryBackingStoreTest, MigrateVersion67To68) {
2886 sql::Connection connection;
2887 ASSERT_TRUE(connection.OpenInMemory());
2889 SetUpVersion67Database(&connection);
2891 // Columns existing before version 67.
2892 ASSERT_TRUE(connection.DoesColumnExist("metas", "name"));
2893 ASSERT_TRUE(connection.DoesColumnExist("metas", "unsanitized_name"));
2894 ASSERT_TRUE(connection.DoesColumnExist("metas", "server_name"));
2896 scoped_ptr<TestDirectoryBackingStore> dbs(
2897 new TestDirectoryBackingStore(GetUsername(), &connection));
2899 ASSERT_FALSE(dbs->needs_column_refresh_);
2900 ASSERT_TRUE(dbs->MigrateVersion67To68());
2901 ASSERT_EQ(68, dbs->GetVersion());
2902 ASSERT_TRUE(dbs->needs_column_refresh_);
2905 TEST_F(DirectoryBackingStoreTest, MigrateVersion68To69) {
2906 sql::Connection connection;
2907 ASSERT_TRUE(connection.OpenInMemory());
2908 SetUpVersion68Database(&connection);
2911 scoped_ptr<TestDirectoryBackingStore> dbs(
2912 new TestDirectoryBackingStore(GetUsername(), &connection));
2914 ASSERT_FALSE(dbs->needs_column_refresh_);
2915 ASSERT_TRUE(dbs->MigrateVersion68To69());
2916 ASSERT_EQ(69, dbs->GetVersion());
2917 ASSERT_TRUE(dbs->needs_column_refresh_);
2920 ASSERT_TRUE(connection.DoesColumnExist("metas", "specifics"));
2921 ASSERT_TRUE(connection.DoesColumnExist("metas", "server_specifics"));
2922 sql::Statement s(connection.GetUniqueStatement("SELECT non_unique_name,"
2923 "is_del, is_dir, id, specifics, server_specifics FROM metas "
2924 "WHERE metahandle = 2"));
2925 ASSERT_TRUE(s.Step());
2926 ASSERT_EQ("Deleted Item", s.ColumnString(0));
2927 ASSERT_TRUE(s.ColumnBool(1));
2928 ASSERT_FALSE(s.ColumnBool(2));
2929 ASSERT_EQ("s_ID_2", s.ColumnString(3));
2930 sync_pb::EntitySpecifics specifics;
2931 specifics.ParseFromArray(s.ColumnBlob(4), s.ColumnByteLength(4));
2932 ASSERT_TRUE(specifics.has_bookmark());
2933 ASSERT_EQ("http://www.google.com/", specifics.bookmark().url());
2934 ASSERT_EQ("AASGASGA", specifics.bookmark().favicon());
2935 specifics.ParseFromArray(s.ColumnBlob(5), s.ColumnByteLength(5));
2936 ASSERT_TRUE(specifics.has_bookmark());
2937 ASSERT_EQ("http://www.google.com/2", specifics.bookmark().url());
2938 ASSERT_EQ("ASADGADGADG", specifics.bookmark().favicon());
2939 ASSERT_FALSE(s.Step());
2942 TEST_F(DirectoryBackingStoreTest, MigrateVersion69To70) {
2943 sql::Connection connection;
2944 ASSERT_TRUE(connection.OpenInMemory());
2945 SetUpVersion69Database(&connection);
2947 ASSERT_TRUE(connection.DoesColumnExist("metas", "singleton_tag"));
2948 ASSERT_FALSE(connection.DoesColumnExist("metas", "unique_server_tag"));
2949 ASSERT_FALSE(connection.DoesColumnExist("metas", "unique_client_tag"));
2952 scoped_ptr<TestDirectoryBackingStore> dbs(
2953 new TestDirectoryBackingStore(GetUsername(), &connection));
2955 ASSERT_FALSE(dbs->needs_column_refresh_);
2956 ASSERT_TRUE(dbs->MigrateVersion69To70());
2957 ASSERT_EQ(70, dbs->GetVersion());
2958 ASSERT_TRUE(dbs->needs_column_refresh_);
2961 EXPECT_TRUE(connection.DoesColumnExist("metas", "unique_server_tag"));
2962 EXPECT_TRUE(connection.DoesColumnExist("metas", "unique_client_tag"));
2963 sql::Statement s(connection.GetUniqueStatement("SELECT id"
2964 " FROM metas WHERE unique_server_tag = 'google_chrome'"));
2965 ASSERT_TRUE(s.Step());
2966 EXPECT_EQ("s_ID_7", s.ColumnString(0));
2969 TEST_F(DirectoryBackingStoreTest, MigrateVersion70To71) {
2970 sql::Connection connection;
2971 ASSERT_TRUE(connection.OpenInMemory());
2972 SetUpVersion70Database(&connection);
2974 ASSERT_TRUE(connection.DoesColumnExist("share_info", "last_sync_timestamp"));
2975 ASSERT_TRUE(connection.DoesColumnExist("share_info", "initial_sync_ended"));
2976 ASSERT_FALSE(connection.DoesTableExist("models"));
2979 scoped_ptr<TestDirectoryBackingStore> dbs(
2980 new TestDirectoryBackingStore(GetUsername(), &connection));
2982 ASSERT_FALSE(dbs->needs_column_refresh_);
2983 ASSERT_TRUE(dbs->MigrateVersion70To71());
2984 ASSERT_EQ(71, dbs->GetVersion());
2985 ASSERT_FALSE(dbs->needs_column_refresh_);
2988 ASSERT_FALSE(connection.DoesColumnExist("share_info", "last_sync_timestamp"));
2989 ASSERT_FALSE(connection.DoesColumnExist("share_info", "initial_sync_ended"));
2990 ASSERT_TRUE(connection.DoesTableExist("models"));
2991 ASSERT_TRUE(connection.DoesColumnExist("models", "initial_sync_ended"));
2992 ASSERT_TRUE(connection.DoesColumnExist("models", "last_download_timestamp"));
2993 ASSERT_TRUE(connection.DoesColumnExist("models", "model_id"));
2995 sql::Statement s(connection.GetUniqueStatement("SELECT model_id, "
2996 "initial_sync_ended, last_download_timestamp FROM models"));
2997 ASSERT_TRUE(s.Step());
2998 std::string model_id = s.ColumnString(0);
2999 EXPECT_EQ("C2881000", base::HexEncode(model_id.data(), model_id.size()))
3000 << "Model ID is expected to be the empty BookmarkSpecifics proto.";
3001 EXPECT_TRUE(s.ColumnBool(1));
3002 EXPECT_EQ(694, s.ColumnInt64(2));
3003 ASSERT_FALSE(s.Step());
3007 TEST_F(DirectoryBackingStoreTest, MigrateVersion71To72) {
3008 sql::Connection connection;
3009 ASSERT_TRUE(connection.OpenInMemory());
3010 SetUpVersion71Database(&connection);
3012 ASSERT_TRUE(connection.DoesTableExist("extended_attributes"));
3015 scoped_ptr<TestDirectoryBackingStore> dbs(
3016 new TestDirectoryBackingStore(GetUsername(), &connection));
3018 ASSERT_FALSE(dbs->needs_column_refresh_);
3019 ASSERT_TRUE(dbs->MigrateVersion71To72());
3020 ASSERT_EQ(72, dbs->GetVersion());
3021 ASSERT_FALSE(dbs->needs_column_refresh_);
3024 ASSERT_FALSE(connection.DoesTableExist("extended_attributes"));
3027 TEST_F(DirectoryBackingStoreTest, MigrateVersion72To73) {
3028 sql::Connection connection;
3029 ASSERT_TRUE(connection.OpenInMemory());
3030 SetUpVersion72Database(&connection);
3032 ASSERT_FALSE(connection.DoesColumnExist("share_info", "notification_state"));
3035 scoped_ptr<TestDirectoryBackingStore> dbs(
3036 new TestDirectoryBackingStore(GetUsername(), &connection));
3038 ASSERT_FALSE(dbs->needs_column_refresh_);
3039 ASSERT_TRUE(dbs->MigrateVersion72To73());
3040 ASSERT_EQ(73, dbs->GetVersion());
3041 ASSERT_FALSE(dbs->needs_column_refresh_);
3044 ASSERT_TRUE(connection.DoesColumnExist("share_info", "notification_state"));
3047 TEST_F(DirectoryBackingStoreTest, MigrateVersion73To74) {
3048 sql::Connection connection;
3049 ASSERT_TRUE(connection.OpenInMemory());
3050 SetUpVersion73Database(&connection);
3052 ASSERT_FALSE(
3053 connection.DoesColumnExist("share_info", "autofill_migration_state"));
3054 ASSERT_FALSE(
3055 connection.DoesColumnExist("share_info",
3056 "bookmarks_added_during_autofill_migration"));
3057 ASSERT_FALSE(
3058 connection.DoesColumnExist("share_info", "autofill_migration_time"));
3059 ASSERT_FALSE(
3060 connection.DoesColumnExist("share_info",
3061 "autofill_entries_added_during_migration"));
3063 ASSERT_FALSE(
3064 connection.DoesColumnExist("share_info",
3065 "autofill_profiles_added_during_migration"));
3068 scoped_ptr<TestDirectoryBackingStore> dbs(
3069 new TestDirectoryBackingStore(GetUsername(), &connection));
3071 ASSERT_FALSE(dbs->needs_column_refresh_);
3072 ASSERT_TRUE(dbs->MigrateVersion73To74());
3073 ASSERT_EQ(74, dbs->GetVersion());
3074 ASSERT_FALSE(dbs->needs_column_refresh_);
3077 ASSERT_TRUE(
3078 connection.DoesColumnExist("share_info", "autofill_migration_state"));
3079 ASSERT_TRUE(
3080 connection.DoesColumnExist("share_info",
3081 "bookmarks_added_during_autofill_migration"));
3082 ASSERT_TRUE(
3083 connection.DoesColumnExist("share_info", "autofill_migration_time"));
3084 ASSERT_TRUE(
3085 connection.DoesColumnExist("share_info",
3086 "autofill_entries_added_during_migration"));
3088 ASSERT_TRUE(
3089 connection.DoesColumnExist("share_info",
3090 "autofill_profiles_added_during_migration"));
3093 TEST_F(DirectoryBackingStoreTest, MigrateVersion74To75) {
3094 sql::Connection connection;
3095 ASSERT_TRUE(connection.OpenInMemory());
3096 SetUpVersion74Database(&connection);
3098 ASSERT_FALSE(connection.DoesColumnExist("models", "progress_marker"));
3099 ASSERT_TRUE(connection.DoesColumnExist("models", "last_download_timestamp"));
3102 scoped_ptr<TestDirectoryBackingStore> dbs(
3103 new TestDirectoryBackingStore(GetUsername(), &connection));
3105 ASSERT_FALSE(dbs->needs_column_refresh_);
3106 ASSERT_TRUE(dbs->MigrateVersion74To75());
3107 ASSERT_EQ(75, dbs->GetVersion());
3108 ASSERT_FALSE(dbs->needs_column_refresh_);
3111 ASSERT_TRUE(connection.DoesColumnExist("models", "progress_marker"));
3112 ASSERT_FALSE(connection.DoesColumnExist("models", "last_download_timestamp"));
3115 TEST_F(DirectoryBackingStoreTest, MigrateVersion75To76) {
3116 sql::Connection connection;
3117 ASSERT_TRUE(connection.OpenInMemory());
3118 SetUpVersion75Database(&connection);
3120 ASSERT_TRUE(
3121 connection.DoesColumnExist("share_info", "autofill_migration_state"));
3122 ASSERT_TRUE(connection.DoesColumnExist("share_info",
3123 "bookmarks_added_during_autofill_migration"));
3124 ASSERT_TRUE(
3125 connection.DoesColumnExist("share_info", "autofill_migration_time"));
3126 ASSERT_TRUE(connection.DoesColumnExist("share_info",
3127 "autofill_entries_added_during_migration"));
3128 ASSERT_TRUE(connection.DoesColumnExist("share_info",
3129 "autofill_profiles_added_during_migration"));
3131 scoped_ptr<TestDirectoryBackingStore> dbs(
3132 new TestDirectoryBackingStore(GetUsername(), &connection));
3133 ASSERT_FALSE(dbs->needs_column_refresh_);
3134 ASSERT_TRUE(dbs->MigrateVersion75To76());
3135 ASSERT_EQ(76, dbs->GetVersion());
3136 ASSERT_TRUE(dbs->needs_column_refresh_);
3137 // Cannot actual refresh columns due to version 76 not containing all
3138 // necessary columns.
3141 TEST_F(DirectoryBackingStoreTest, MigrateVersion76To77) {
3142 sql::Connection connection;
3143 ASSERT_TRUE(connection.OpenInMemory());
3144 SetUpVersion76Database(&connection);
3146 scoped_ptr<TestDirectoryBackingStore> dbs(
3147 new TestDirectoryBackingStore(GetUsername(), &connection));
3148 ASSERT_FALSE(dbs->needs_column_refresh_);
3150 EXPECT_EQ(GetExpectedLegacyMetaProtoTimes(INCLUDE_DELETED_ITEMS),
3151 GetMetaProtoTimes(dbs->db_.get()));
3152 // Since the proto times are expected to be in a legacy format, they may not
3153 // be compatible with ProtoTimeToTime, so we don't call ExpectTimes().
3155 ASSERT_TRUE(dbs->MigrateVersion76To77());
3156 ASSERT_EQ(77, dbs->GetVersion());
3158 EXPECT_EQ(GetExpectedMetaProtoTimes(INCLUDE_DELETED_ITEMS),
3159 GetMetaProtoTimes(dbs->db_.get()));
3160 // Cannot actually load entries due to version 77 not having all required
3161 // columns.
3162 ASSERT_FALSE(dbs->needs_column_refresh_);
3165 TEST_F(DirectoryBackingStoreTest, MigrateVersion77To78) {
3166 sql::Connection connection;
3167 ASSERT_TRUE(connection.OpenInMemory());
3168 SetUpVersion77Database(&connection);
3170 ASSERT_FALSE(connection.DoesColumnExist("metas", "BASE_SERVER_SPECIFICS"));
3173 scoped_ptr<TestDirectoryBackingStore> dbs(
3174 new TestDirectoryBackingStore(GetUsername(), &connection));
3175 ASSERT_FALSE(dbs->needs_column_refresh_);
3176 ASSERT_TRUE(dbs->MigrateVersion77To78());
3177 ASSERT_EQ(78, dbs->GetVersion());
3179 ASSERT_FALSE(dbs->needs_column_refresh_);
3182 ASSERT_TRUE(connection.DoesColumnExist("metas", "base_server_specifics"));
3185 TEST_F(DirectoryBackingStoreTest, MigrateVersion78To79) {
3186 const int kInitialNextId = -65542;
3188 sql::Connection connection;
3189 ASSERT_TRUE(connection.OpenInMemory());
3190 SetUpVersion78Database(&connection);
3192 // Double-check the original next_id is what we think it is.
3193 sql::Statement s(connection.GetUniqueStatement(
3194 "SELECT next_id FROM share_info"));
3195 s.Step();
3196 ASSERT_EQ(kInitialNextId, s.ColumnInt(0));
3198 scoped_ptr<TestDirectoryBackingStore> dbs(
3199 new TestDirectoryBackingStore(GetUsername(), &connection));
3200 ASSERT_FALSE(dbs->needs_column_refresh_);
3201 ASSERT_TRUE(dbs->MigrateVersion78To79());
3202 ASSERT_EQ(79, dbs->GetVersion());
3203 ASSERT_FALSE(dbs->needs_column_refresh_);
3205 // Ensure the next_id has been incremented.
3206 Directory::MetahandlesMap handles_map;
3207 JournalIndex delete_journals;;
3208 STLValueDeleter<Directory::MetahandlesMap> deleter(&handles_map);
3209 Directory::KernelLoadInfo load_info;
3211 s.Clear();
3212 ASSERT_TRUE(dbs->Load(&handles_map, &delete_journals, &load_info));
3213 EXPECT_LE(load_info.kernel_info.next_id, kInitialNextId - 65536);
3216 TEST_F(DirectoryBackingStoreTest, MigrateVersion79To80) {
3217 sql::Connection connection;
3218 ASSERT_TRUE(connection.OpenInMemory());
3219 SetUpVersion79Database(&connection);
3221 scoped_ptr<TestDirectoryBackingStore> dbs(
3222 new TestDirectoryBackingStore(GetUsername(), &connection));
3223 ASSERT_FALSE(dbs->needs_column_refresh_);
3224 ASSERT_TRUE(dbs->MigrateVersion79To80());
3225 ASSERT_EQ(80, dbs->GetVersion());
3226 ASSERT_FALSE(dbs->needs_column_refresh_);
3228 // Ensure the bag_of_chips has been set.
3229 Directory::MetahandlesMap handles_map;
3230 JournalIndex delete_journals;;
3231 STLValueDeleter<Directory::MetahandlesMap> deleter(&handles_map);
3232 Directory::KernelLoadInfo load_info;
3234 ASSERT_TRUE(dbs->Load(&handles_map, &delete_journals, &load_info));
3235 // Check that the initial value is the serialization of an empty ChipBag.
3236 sync_pb::ChipBag chip_bag;
3237 std::string serialized_chip_bag;
3238 ASSERT_TRUE(chip_bag.SerializeToString(&serialized_chip_bag));
3239 EXPECT_EQ(serialized_chip_bag, load_info.kernel_info.bag_of_chips);
3242 TEST_F(DirectoryBackingStoreTest, MigrateVersion80To81) {
3243 sql::Connection connection;
3244 ASSERT_TRUE(connection.OpenInMemory());
3245 SetUpVersion80Database(&connection);
3247 sql::Statement s(connection.GetUniqueStatement(
3248 "SELECT metahandle, server_position_in_parent "
3249 "FROM metas WHERE unique_server_tag = 'google_chrome'"));
3250 ASSERT_TRUE(s.Step());
3251 ASSERT_EQ(sql::COLUMN_TYPE_INTEGER, s.ColumnType(1));
3253 scoped_ptr<TestDirectoryBackingStore> dbs(
3254 new TestDirectoryBackingStore(GetUsername(), &connection));
3255 ASSERT_TRUE(dbs->MigrateVersion80To81());
3256 ASSERT_EQ(81, dbs->GetVersion());
3258 // Test that ordinal values are preserved correctly.
3259 sql::Statement new_s(connection.GetUniqueStatement(
3260 "SELECT metahandle, server_ordinal_in_parent "
3261 "FROM metas WHERE unique_server_tag = 'google_chrome'"));
3262 ASSERT_TRUE(new_s.Step());
3263 ASSERT_EQ(sql::COLUMN_TYPE_BLOB, new_s.ColumnType(1));
3265 std::string expected_ordinal = Int64ToNodeOrdinal(1048576).ToInternalValue();
3266 std::string actual_ordinal;
3267 new_s.ColumnBlobAsString(1, &actual_ordinal);
3268 ASSERT_EQ(expected_ordinal, actual_ordinal);
3271 TEST_F(DirectoryBackingStoreTest, MigrateVersion81To82) {
3272 sql::Connection connection;
3273 ASSERT_TRUE(connection.OpenInMemory());
3274 SetUpVersion81Database(&connection);
3275 ASSERT_FALSE(connection.DoesColumnExist("models", "transaction_version"));
3277 scoped_ptr<TestDirectoryBackingStore> dbs(
3278 new TestDirectoryBackingStore(GetUsername(), &connection));
3279 ASSERT_FALSE(dbs->needs_column_refresh_);
3280 ASSERT_TRUE(dbs->MigrateVersion81To82());
3281 ASSERT_EQ(82, dbs->GetVersion());
3282 ASSERT_FALSE(dbs->needs_column_refresh_);
3284 ASSERT_TRUE(connection.DoesColumnExist("models", "transaction_version"));
3287 TEST_F(DirectoryBackingStoreTest, MigrateVersion82To83) {
3288 sql::Connection connection;
3289 ASSERT_TRUE(connection.OpenInMemory());
3290 SetUpVersion82Database(&connection);
3291 ASSERT_FALSE(connection.DoesColumnExist("metas", "transaction_version"));
3293 scoped_ptr<TestDirectoryBackingStore> dbs(
3294 new TestDirectoryBackingStore(GetUsername(), &connection));
3295 ASSERT_TRUE(dbs->MigrateVersion82To83());
3296 ASSERT_EQ(83, dbs->GetVersion());
3298 ASSERT_TRUE(connection.DoesColumnExist("metas", "transaction_version"));
3301 TEST_F(DirectoryBackingStoreTest, MigrateVersion83To84) {
3302 sql::Connection connection;
3303 ASSERT_TRUE(connection.OpenInMemory());
3304 SetUpVersion83Database(&connection);
3305 ASSERT_FALSE(connection.DoesTableExist("deleted_metas"));
3307 scoped_ptr<TestDirectoryBackingStore> dbs(
3308 new TestDirectoryBackingStore(GetUsername(), &connection));
3309 ASSERT_TRUE(dbs->MigrateVersion83To84());
3310 ASSERT_EQ(84, dbs->GetVersion());
3312 ASSERT_TRUE(connection.DoesTableExist("deleted_metas"));
3315 TEST_F(DirectoryBackingStoreTest, MigrateVersion84To85) {
3316 sql::Connection connection;
3317 ASSERT_TRUE(connection.OpenInMemory());
3318 SetUpVersion84Database(&connection);
3319 ASSERT_TRUE(connection.DoesColumnExist("models", "initial_sync_ended"));
3321 scoped_ptr<TestDirectoryBackingStore> dbs(
3322 new TestDirectoryBackingStore(GetUsername(), &connection));
3323 ASSERT_TRUE(dbs->MigrateVersion84To85());
3324 ASSERT_EQ(85, dbs->GetVersion());
3325 ASSERT_FALSE(connection.DoesColumnExist("models", "initial_sync_ended"));
3328 TEST_F(DirectoryBackingStoreTest, MigrateVersion85To86) {
3329 sql::Connection connection;
3330 ASSERT_TRUE(connection.OpenInMemory());
3331 SetUpVersion85Database(&connection);
3332 EXPECT_TRUE(connection.DoesColumnExist("metas", "next_id"));
3333 EXPECT_TRUE(connection.DoesColumnExist("metas", "prev_id"));
3334 EXPECT_TRUE(connection.DoesColumnExist("metas", "server_ordinal_in_parent"));
3335 EXPECT_FALSE(connection.DoesColumnExist("metas", "unique_position"));
3336 EXPECT_FALSE(connection.DoesColumnExist("metas", "server_unique_position"));
3337 EXPECT_FALSE(connection.DoesColumnExist("metas", "unique_bookmark_tag"));
3339 scoped_ptr<TestDirectoryBackingStore> dbs(
3340 new TestDirectoryBackingStore(GetUsername(), &connection));
3341 ASSERT_TRUE(dbs->MigrateVersion85To86());
3342 EXPECT_EQ(86, dbs->GetVersion());
3343 EXPECT_TRUE(connection.DoesColumnExist("metas", "unique_position"));
3344 EXPECT_TRUE(connection.DoesColumnExist("metas", "server_unique_position"));
3345 EXPECT_TRUE(connection.DoesColumnExist("metas", "unique_bookmark_tag"));
3346 ASSERT_TRUE(dbs->needs_column_refresh_);
3349 TEST_F(DirectoryBackingStoreTest, MigrateVersion86To87) {
3350 sql::Connection connection;
3351 EXPECT_TRUE(connection.OpenInMemory());
3352 SetUpVersion86Database(&connection);
3353 EXPECT_FALSE(connection.DoesColumnExist("metas", "attachment_metadata"));
3355 scoped_ptr<TestDirectoryBackingStore> dbs(
3356 new TestDirectoryBackingStore(GetUsername(), &connection));
3357 EXPECT_TRUE(dbs->MigrateVersion86To87());
3358 EXPECT_EQ(87, dbs->GetVersion());
3359 EXPECT_TRUE(connection.DoesColumnExist("metas", "attachment_metadata"));
3360 EXPECT_TRUE(dbs->needs_column_refresh_);
3363 TEST_F(DirectoryBackingStoreTest, MigrateVersion87To88) {
3364 sql::Connection connection;
3365 ASSERT_TRUE(connection.OpenInMemory());
3366 SetUpVersion87Database(&connection);
3368 scoped_ptr<TestDirectoryBackingStore> dbs(
3369 new TestDirectoryBackingStore(GetUsername(), &connection));
3370 ASSERT_TRUE(dbs->MigrateVersion87To88());
3371 ASSERT_EQ(88, dbs->GetVersion());
3372 ASSERT_TRUE(connection.DoesColumnExist("models", "context"));
3375 TEST_F(DirectoryBackingStoreTest, MigrateVersion88To89) {
3376 sql::Connection connection;
3377 ASSERT_TRUE(connection.OpenInMemory());
3378 SetUpVersion88Database(&connection);
3379 ASSERT_FALSE(
3380 connection.DoesColumnExist("metas", "server_attachment_metadata"));
3382 scoped_ptr<TestDirectoryBackingStore> dbs(
3383 new TestDirectoryBackingStore(GetUsername(), &connection));
3384 ASSERT_TRUE(dbs->MigrateVersion88To89());
3385 ASSERT_EQ(89, dbs->GetVersion());
3386 EXPECT_TRUE(
3387 connection.DoesColumnExist("metas", "server_attachment_metadata"));
3388 EXPECT_TRUE(dbs->needs_column_refresh_);
3391 // The purpose of this test case is to make it easier to get a dump of the
3392 // database so you can implement a SetUpVersionYDatabase method. Here's what
3393 // you should do:
3395 // 1. Say you're going from version X to version Y. Write the migration
3396 // method MigrateVersionXToY.
3397 // 2. Update the test below to call SetUpVersionXDatabase and then
3398 // MigrateVersionXToY. You now have a database at version Y. Let's dump it.
3399 // 3. Set a breakpoint to stop execution just after the connection is
3400 // destroyed. Examine temp_dir_ to find the version Y database that was
3401 // created on disk. E.g. (gdb) p temp_dir_.path().value().c_str()
3402 // 4. Dump the database using the sqlite3 command line tool:
3403 // > .output foo_dump.sql
3404 // > .dump
3405 // 5. Replace the timestamp columns with META_PROTO_TIMES(x) (or
3406 // LEGACY_META_PROTO_TIMES(x) if before Version 77). Use this dump to write
3407 // a SetupVersionYDatabase method.
3408 TEST_F(DirectoryBackingStoreTest, MigrateToLatestAndDump) {
3410 sql::Connection connection;
3411 ASSERT_TRUE(connection.Open(GetDatabasePath()));
3412 SetUpVersion88Database(&connection); // Update this.
3414 scoped_ptr<TestDirectoryBackingStore> dbs(
3415 new TestDirectoryBackingStore(GetUsername(), &connection));
3416 ASSERT_TRUE(dbs->MigrateVersion88To89()); // Update this.
3417 ASSERT_TRUE(LoadAndIgnoreReturnedData(dbs.get()));
3418 EXPECT_EQ(89, dbs->GetVersion()); // Update this.
3419 ASSERT_FALSE(dbs->needs_column_refresh_);
3421 // Set breakpoint here.
3424 TEST_F(DirectoryBackingStoreTest, DetectInvalidPosition) {
3425 sql::Connection connection;
3426 ASSERT_TRUE(connection.OpenInMemory());
3427 SetUpVersion86Database(&connection);
3429 scoped_ptr<TestDirectoryBackingStore> dbs(
3430 new TestDirectoryBackingStore(GetUsername(), &connection));
3431 ASSERT_EQ(86, dbs->GetVersion());
3433 // Insert row with bad position.
3434 sql::Statement s(connection.GetUniqueStatement(
3435 "INSERT INTO metas "
3436 "( id, metahandle, is_dir, ctime, mtime,"
3437 " unique_position, server_unique_position) "
3438 "VALUES('c-invalid', 9999, 1, 0, 0, 'BAD_POS', 'BAD_POS')"));
3439 ASSERT_TRUE(s.Run());
3441 // Trying to unpack this entry should signal that the DB is corrupted.
3442 Directory::MetahandlesMap handles_map;
3443 JournalIndex delete_journals;;
3444 STLValueDeleter<Directory::MetahandlesMap> deleter(&handles_map);
3445 Directory::KernelLoadInfo kernel_load_info;
3446 ASSERT_EQ(FAILED_DATABASE_CORRUPT,
3447 dbs->Load(&handles_map, &delete_journals, &kernel_load_info));
3450 TEST_P(MigrationTest, ToCurrentVersion) {
3451 sql::Connection connection;
3452 ASSERT_TRUE(connection.OpenInMemory());
3453 switch (GetParam()) {
3454 case 67:
3455 SetUpVersion67Database(&connection);
3456 break;
3457 case 68:
3458 SetUpVersion68Database(&connection);
3459 break;
3460 case 69:
3461 SetUpVersion69Database(&connection);
3462 break;
3463 case 70:
3464 SetUpVersion70Database(&connection);
3465 break;
3466 case 71:
3467 SetUpVersion71Database(&connection);
3468 break;
3469 case 72:
3470 SetUpVersion72Database(&connection);
3471 break;
3472 case 73:
3473 SetUpVersion73Database(&connection);
3474 break;
3475 case 74:
3476 SetUpVersion74Database(&connection);
3477 break;
3478 case 75:
3479 SetUpVersion75Database(&connection);
3480 break;
3481 case 76:
3482 SetUpVersion76Database(&connection);
3483 break;
3484 case 77:
3485 SetUpVersion77Database(&connection);
3486 break;
3487 case 78:
3488 SetUpVersion78Database(&connection);
3489 break;
3490 case 79:
3491 SetUpVersion79Database(&connection);
3492 break;
3493 case 80:
3494 SetUpVersion80Database(&connection);
3495 break;
3496 case 81:
3497 SetUpVersion81Database(&connection);
3498 break;
3499 case 82:
3500 SetUpVersion82Database(&connection);
3501 break;
3502 case 83:
3503 SetUpVersion83Database(&connection);
3504 break;
3505 case 84:
3506 SetUpVersion84Database(&connection);
3507 break;
3508 case 85:
3509 SetUpVersion85Database(&connection);
3510 break;
3511 case 86:
3512 SetUpVersion86Database(&connection);
3513 break;
3514 case 87:
3515 SetUpVersion87Database(&connection);
3516 break;
3517 case 88:
3518 SetUpVersion88Database(&connection);
3519 break;
3520 case 89:
3521 SetUpVersion89Database(&connection);
3522 break;
3523 default:
3524 // If you see this error, it may mean that you've increased the
3525 // database version number but you haven't finished adding unit tests
3526 // for the database migration code. You need to need to supply a
3527 // SetUpVersionYDatabase function with a dump of the test database
3528 // at the new schema. See the MigrateToLatestAndDump test case.
3529 FAIL() << "Need to supply database dump for version " << GetParam();
3532 syncable::Directory::KernelLoadInfo dir_info;
3533 Directory::MetahandlesMap handles_map;
3534 JournalIndex delete_journals;;
3535 STLValueDeleter<Directory::MetahandlesMap> index_deleter(&handles_map);
3538 scoped_ptr<TestDirectoryBackingStore> dbs(
3539 new TestDirectoryBackingStore(GetUsername(), &connection));
3540 ASSERT_EQ(OPENED, dbs->Load(&handles_map, &delete_journals, &dir_info));
3541 ASSERT_FALSE(dbs->needs_column_refresh_);
3542 ASSERT_EQ(kCurrentDBVersion, dbs->GetVersion());
3545 // Columns deleted in Version 67.
3546 ASSERT_FALSE(connection.DoesColumnExist("metas", "name"));
3547 ASSERT_FALSE(connection.DoesColumnExist("metas", "unsanitized_name"));
3548 ASSERT_FALSE(connection.DoesColumnExist("metas", "server_name"));
3550 // Columns added in Version 68.
3551 ASSERT_TRUE(connection.DoesColumnExist("metas", "specifics"));
3552 ASSERT_TRUE(connection.DoesColumnExist("metas", "server_specifics"));
3554 // Columns deleted in Version 68.
3555 ASSERT_FALSE(connection.DoesColumnExist("metas", "is_bookmark_object"));
3556 ASSERT_FALSE(connection.DoesColumnExist("metas",
3557 "server_is_bookmark_object"));
3558 ASSERT_FALSE(connection.DoesColumnExist("metas", "bookmark_favicon"));
3559 ASSERT_FALSE(connection.DoesColumnExist("metas", "bookmark_url"));
3560 ASSERT_FALSE(connection.DoesColumnExist("metas", "server_bookmark_url"));
3562 // Renamed a column in Version 70
3563 ASSERT_FALSE(connection.DoesColumnExist("metas", "singleton_tag"));
3564 ASSERT_TRUE(connection.DoesColumnExist("metas", "unique_server_tag"));
3565 ASSERT_TRUE(connection.DoesColumnExist("metas", "unique_client_tag"));
3567 // Removed extended attributes in Version 72.
3568 ASSERT_FALSE(connection.DoesTableExist("extended_attributes"));
3570 // Columns added in Version 73.
3571 ASSERT_TRUE(connection.DoesColumnExist("share_info", "notification_state"));
3573 // Column replaced in version 75.
3574 ASSERT_TRUE(connection.DoesColumnExist("models", "progress_marker"));
3575 ASSERT_FALSE(connection.DoesColumnExist("models", "last_download_timestamp"));
3577 // Columns removed in version 76.
3578 ASSERT_FALSE(
3579 connection.DoesColumnExist("share_info", "autofill_migration_state"));
3580 ASSERT_FALSE(connection.DoesColumnExist("share_info",
3581 "bookmarks_added_during_autofill_migration"));
3582 ASSERT_FALSE(
3583 connection.DoesColumnExist("share_info", "autofill_migration_time"));
3584 ASSERT_FALSE(connection.DoesColumnExist("share_info",
3585 "autofill_entries_added_during_migration"));
3586 ASSERT_FALSE(connection.DoesColumnExist("share_info",
3587 "autofill_profiles_added_during_migration"));
3589 // Column added in version 78.
3590 ASSERT_TRUE(connection.DoesColumnExist("metas", "base_server_specifics"));
3592 // Column added in version 82.
3593 ASSERT_TRUE(connection.DoesColumnExist("models", "transaction_version"));
3595 // Column added in version 83.
3596 ASSERT_TRUE(connection.DoesColumnExist("metas", "transaction_version"));
3598 // Table added in version 84.
3599 ASSERT_TRUE(connection.DoesTableExist("deleted_metas"));
3601 // Column removed in version 85.
3602 ASSERT_FALSE(connection.DoesColumnExist("models", "initial_sync_ended"));
3604 // Columns removed in version 86.
3605 ASSERT_FALSE(connection.DoesColumnExist("metas", "next_id"));
3606 ASSERT_FALSE(connection.DoesColumnExist("metas", "prev_id"));
3607 ASSERT_FALSE(connection.DoesColumnExist("metas", "server_ordinal_in_parent"));
3609 // Column added in version 87.
3610 ASSERT_TRUE(connection.DoesColumnExist("metas", "attachment_metadata"));
3612 // Column added in version 88.
3613 ASSERT_TRUE(connection.DoesColumnExist("models", "context"));
3615 // Column added in version 89.
3616 ASSERT_TRUE(
3617 connection.DoesColumnExist("metas", "server_attachment_metadata"));
3619 // Check download_progress state (v75 migration)
3620 ASSERT_EQ(694,
3621 dir_info.kernel_info.download_progress[BOOKMARKS]
3622 .timestamp_token_for_migration());
3623 ASSERT_FALSE(
3624 dir_info.kernel_info.download_progress[BOOKMARKS]
3625 .has_token());
3626 ASSERT_EQ(32904,
3627 dir_info.kernel_info.download_progress[BOOKMARKS]
3628 .data_type_id());
3629 ASSERT_FALSE(
3630 dir_info.kernel_info.download_progress[THEMES]
3631 .has_timestamp_token_for_migration());
3632 ASSERT_TRUE(
3633 dir_info.kernel_info.download_progress[THEMES]
3634 .has_token());
3635 ASSERT_TRUE(
3636 dir_info.kernel_info.download_progress[THEMES]
3637 .token().empty());
3638 ASSERT_EQ(41210,
3639 dir_info.kernel_info.download_progress[THEMES]
3640 .data_type_id());
3642 // Check metas
3643 EXPECT_EQ(GetExpectedMetaProtoTimes(DONT_INCLUDE_DELETED_ITEMS),
3644 GetMetaProtoTimes(&connection));
3645 ExpectTimes(handles_map, GetExpectedMetaTimes());
3647 Directory::MetahandlesMap::iterator it = handles_map.find(1);
3648 ASSERT_TRUE(it != handles_map.end());
3649 ASSERT_EQ(1, it->second->ref(META_HANDLE));
3650 EXPECT_TRUE(it->second->ref(ID).IsRoot());
3651 EXPECT_FALSE(it->second->ref(UNIQUE_POSITION).IsValid());
3652 EXPECT_FALSE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3653 EXPECT_TRUE(it->second->ref(UNIQUE_BOOKMARK_TAG).empty());
3654 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3655 EXPECT_TRUE(it->second->ref(SERVER_ATTACHMENT_METADATA).IsInitialized());
3657 // Items 2, 4, and 5 were deleted.
3658 it = handles_map.find(2);
3659 ASSERT_TRUE(it == handles_map.end());
3660 it = handles_map.find(4);
3661 ASSERT_TRUE(it == handles_map.end());
3662 it = handles_map.find(5);
3663 ASSERT_TRUE(it == handles_map.end());
3665 it = handles_map.find(6);
3666 ASSERT_EQ(6, it->second->ref(META_HANDLE));
3667 EXPECT_TRUE(it->second->ref(IS_DIR));
3668 EXPECT_TRUE(it->second->ref(SERVER_IS_DIR));
3669 EXPECT_FALSE(it->second->ref(SPECIFICS).bookmark().has_url());
3670 EXPECT_FALSE(it->second->ref(SERVER_SPECIFICS).bookmark().has_url());
3671 EXPECT_FALSE(it->second->ref(SPECIFICS).bookmark().has_favicon());
3672 EXPECT_FALSE(it->second->ref(SERVER_SPECIFICS).bookmark().has_favicon());
3673 EXPECT_TRUE(it->second->ref(UNIQUE_POSITION).IsValid());
3674 EXPECT_TRUE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3675 EXPECT_EQ(UniquePosition::kSuffixLength,
3676 it->second->ref(UNIQUE_BOOKMARK_TAG).length());
3677 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3678 EXPECT_TRUE(it->second->ref(SERVER_ATTACHMENT_METADATA).IsInitialized());
3680 it = handles_map.find(7);
3681 ASSERT_EQ(7, it->second->ref(META_HANDLE));
3682 EXPECT_EQ("google_chrome", it->second->ref(UNIQUE_SERVER_TAG));
3683 EXPECT_FALSE(it->second->ref(SPECIFICS).has_bookmark());
3684 EXPECT_FALSE(it->second->ref(SERVER_SPECIFICS).has_bookmark());
3685 // Make sure we didn't assign positions to google_chrome.
3686 EXPECT_FALSE(it->second->ref(UNIQUE_POSITION).IsValid());
3687 EXPECT_FALSE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3688 EXPECT_TRUE(it->second->ref(UNIQUE_BOOKMARK_TAG).empty());
3689 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3690 EXPECT_TRUE(it->second->ref(SERVER_ATTACHMENT_METADATA).IsInitialized());
3692 it = handles_map.find(8);
3693 ASSERT_EQ(8, it->second->ref(META_HANDLE));
3694 EXPECT_EQ("google_chrome_bookmarks", it->second->ref(UNIQUE_SERVER_TAG));
3695 EXPECT_TRUE(it->second->ref(SPECIFICS).has_bookmark());
3696 EXPECT_TRUE(it->second->ref(SERVER_SPECIFICS).has_bookmark());
3697 ASSERT_EQ(it->second->ref(ID).value(), "s_ID_8");
3698 // Make sure we didn't mistake the bookmark root node for a real bookmark.
3699 EXPECT_FALSE(it->second->ref(UNIQUE_POSITION).IsValid());
3700 EXPECT_FALSE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3701 EXPECT_TRUE(it->second->ref(UNIQUE_BOOKMARK_TAG).empty());
3702 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3703 EXPECT_TRUE(it->second->ref(SERVER_ATTACHMENT_METADATA).IsInitialized());
3705 it = handles_map.find(9);
3706 ASSERT_EQ(9, it->second->ref(META_HANDLE));
3707 EXPECT_EQ("bookmark_bar", it->second->ref(UNIQUE_SERVER_TAG));
3708 EXPECT_TRUE(it->second->ref(SPECIFICS).has_bookmark());
3709 EXPECT_TRUE(it->second->ref(SERVER_SPECIFICS).has_bookmark());
3710 // Make sure we didn't assign positions to bookmark_bar.
3711 EXPECT_FALSE(it->second->ref(UNIQUE_POSITION).IsValid());
3712 EXPECT_FALSE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3713 EXPECT_TRUE(it->second->ref(UNIQUE_BOOKMARK_TAG).empty());
3714 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3715 EXPECT_TRUE(it->second->ref(SERVER_ATTACHMENT_METADATA).IsInitialized());
3717 it = handles_map.find(10);
3718 ASSERT_EQ(10, it->second->ref(META_HANDLE));
3719 EXPECT_FALSE(it->second->ref(IS_DEL));
3720 EXPECT_TRUE(it->second->ref(SPECIFICS).has_bookmark());
3721 EXPECT_TRUE(it->second->ref(SERVER_SPECIFICS).has_bookmark());
3722 EXPECT_FALSE(it->second->ref(SPECIFICS).bookmark().has_url());
3723 EXPECT_FALSE(it->second->ref(SPECIFICS).bookmark().has_favicon());
3724 EXPECT_FALSE(it->second->ref(SERVER_SPECIFICS).bookmark().has_url());
3725 EXPECT_FALSE(it->second->ref(SERVER_SPECIFICS).bookmark().has_favicon());
3726 EXPECT_EQ("other_bookmarks", it->second->ref(UNIQUE_SERVER_TAG));
3727 EXPECT_EQ("Other Bookmarks", it->second->ref(NON_UNIQUE_NAME));
3728 EXPECT_EQ("Other Bookmarks", it->second->ref(SERVER_NON_UNIQUE_NAME));
3729 ASSERT_EQ(it->second->ref(ID).value(), "s_ID_10");
3730 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3731 EXPECT_TRUE(it->second->ref(SERVER_ATTACHMENT_METADATA).IsInitialized());
3732 // Make sure we didn't assign positions to server-created folders, either.
3733 EXPECT_FALSE(it->second->ref(UNIQUE_POSITION).IsValid());
3734 EXPECT_FALSE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3735 EXPECT_TRUE(it->second->ref(UNIQUE_BOOKMARK_TAG).empty());
3736 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3737 EXPECT_TRUE(it->second->ref(SERVER_ATTACHMENT_METADATA).IsInitialized());
3739 it = handles_map.find(11);
3740 ASSERT_EQ(11, it->second->ref(META_HANDLE));
3741 EXPECT_FALSE(it->second->ref(IS_DEL));
3742 EXPECT_FALSE(it->second->ref(IS_DIR));
3743 EXPECT_TRUE(it->second->ref(SPECIFICS).has_bookmark());
3744 EXPECT_TRUE(it->second->ref(SERVER_SPECIFICS).has_bookmark());
3745 EXPECT_EQ("http://dev.chromium.org/",
3746 it->second->ref(SPECIFICS).bookmark().url());
3747 EXPECT_EQ("AGATWA", it->second->ref(SPECIFICS).bookmark().favicon());
3748 EXPECT_EQ("http://dev.chromium.org/other",
3749 it->second->ref(SERVER_SPECIFICS).bookmark().url());
3750 EXPECT_EQ("AFAGVASF", it->second->ref(SERVER_SPECIFICS).bookmark().favicon());
3751 EXPECT_EQ("", it->second->ref(UNIQUE_SERVER_TAG));
3752 EXPECT_EQ("Home (The Chromium Projects)", it->second->ref(NON_UNIQUE_NAME));
3753 EXPECT_EQ("Home (The Chromium Projects)",
3754 it->second->ref(SERVER_NON_UNIQUE_NAME));
3755 EXPECT_TRUE(it->second->ref(UNIQUE_POSITION).IsValid());
3756 EXPECT_TRUE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3757 EXPECT_EQ(UniquePosition::kSuffixLength,
3758 it->second->ref(UNIQUE_BOOKMARK_TAG).length());
3759 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3761 it = handles_map.find(12);
3762 ASSERT_EQ(12, it->second->ref(META_HANDLE));
3763 EXPECT_FALSE(it->second->ref(IS_DEL));
3764 EXPECT_TRUE(it->second->ref(IS_DIR));
3765 EXPECT_EQ("Extra Bookmarks", it->second->ref(NON_UNIQUE_NAME));
3766 EXPECT_EQ("Extra Bookmarks", it->second->ref(SERVER_NON_UNIQUE_NAME));
3767 EXPECT_TRUE(it->second->ref(SPECIFICS).has_bookmark());
3768 EXPECT_TRUE(it->second->ref(SERVER_SPECIFICS).has_bookmark());
3769 EXPECT_FALSE(it->second->ref(SPECIFICS).bookmark().has_url());
3770 EXPECT_FALSE(it->second->ref(SERVER_SPECIFICS).bookmark().has_url());
3771 EXPECT_FALSE(it->second->ref(SPECIFICS).bookmark().has_favicon());
3772 EXPECT_FALSE(it->second->ref(SERVER_SPECIFICS).bookmark().has_favicon());
3773 EXPECT_TRUE(it->second->ref(UNIQUE_POSITION).IsValid());
3774 EXPECT_TRUE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3775 EXPECT_EQ(UniquePosition::kSuffixLength,
3776 it->second->ref(UNIQUE_BOOKMARK_TAG).length());
3777 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3778 EXPECT_TRUE(it->second->ref(SERVER_ATTACHMENT_METADATA).IsInitialized());
3780 it = handles_map.find(13);
3781 ASSERT_EQ(13, it->second->ref(META_HANDLE));
3782 EXPECT_TRUE(it->second->ref(UNIQUE_POSITION).IsValid());
3783 EXPECT_TRUE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3784 EXPECT_EQ(UniquePosition::kSuffixLength,
3785 it->second->ref(UNIQUE_BOOKMARK_TAG).length());
3786 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3787 EXPECT_TRUE(it->second->ref(SERVER_ATTACHMENT_METADATA).IsInitialized());
3789 it = handles_map.find(14);
3790 ASSERT_EQ(14, it->second->ref(META_HANDLE));
3791 EXPECT_TRUE(it->second->ref(UNIQUE_POSITION).IsValid());
3792 EXPECT_TRUE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3793 EXPECT_EQ(UniquePosition::kSuffixLength,
3794 it->second->ref(UNIQUE_BOOKMARK_TAG).length());
3795 EXPECT_TRUE(it->second->ref(ATTACHMENT_METADATA).IsInitialized());
3796 EXPECT_TRUE(it->second->ref(SERVER_ATTACHMENT_METADATA).IsInitialized());
3798 ASSERT_EQ(static_cast<size_t>(10), handles_map.size());
3800 // Make sure that the syncable::Directory and the migration code agree on
3801 // which items should or should not have unique position values. This test
3802 // may become obsolete if the directory's definition of that function
3803 // changes, but, until then, this is a useful test.
3804 for (it = handles_map.begin(); it != handles_map.end(); it++) {
3805 SCOPED_TRACE(it->second->ref(ID));
3806 if (it->second->ShouldMaintainPosition()) {
3807 EXPECT_TRUE(it->second->ref(UNIQUE_POSITION).IsValid());
3808 EXPECT_TRUE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3809 EXPECT_FALSE(it->second->ref(UNIQUE_BOOKMARK_TAG).empty());
3810 } else {
3811 EXPECT_FALSE(it->second->ref(UNIQUE_POSITION).IsValid());
3812 EXPECT_FALSE(it->second->ref(SERVER_UNIQUE_POSITION).IsValid());
3813 EXPECT_TRUE(it->second->ref(UNIQUE_BOOKMARK_TAG).empty());
3818 INSTANTIATE_TEST_CASE_P(DirectoryBackingStore, MigrationTest,
3819 testing::Range(67, kCurrentDBVersion + 1));
3821 TEST_F(DirectoryBackingStoreTest, ModelTypeIds) {
3822 ModelTypeSet protocol_types = ProtocolTypes();
3823 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good();
3824 iter.Inc()) {
3825 std::string model_id =
3826 TestDirectoryBackingStore::ModelTypeEnumToModelId(iter.Get());
3827 EXPECT_EQ(iter.Get(),
3828 TestDirectoryBackingStore::ModelIdToModelTypeEnum(model_id.data(),
3829 model_id.size()));
3833 namespace {
3835 class OnDiskDirectoryBackingStoreForTest : public OnDiskDirectoryBackingStore {
3836 public:
3837 OnDiskDirectoryBackingStoreForTest(const std::string& dir_name,
3838 const base::FilePath& backing_filepath);
3839 virtual ~OnDiskDirectoryBackingStoreForTest();
3840 bool DidFailFirstOpenAttempt();
3842 protected:
3843 virtual void ReportFirstTryOpenFailure() OVERRIDE;
3845 private:
3846 bool first_open_failed_;
3849 OnDiskDirectoryBackingStoreForTest::OnDiskDirectoryBackingStoreForTest(
3850 const std::string& dir_name,
3851 const base::FilePath& backing_filepath) :
3852 OnDiskDirectoryBackingStore(dir_name, backing_filepath),
3853 first_open_failed_(false) { }
3855 OnDiskDirectoryBackingStoreForTest::~OnDiskDirectoryBackingStoreForTest() { }
3857 void OnDiskDirectoryBackingStoreForTest::ReportFirstTryOpenFailure() {
3858 // Do nothing, just like we would in release-mode. In debug mode, we DCHECK.
3859 first_open_failed_ = true;
3862 bool OnDiskDirectoryBackingStoreForTest::DidFailFirstOpenAttempt() {
3863 return first_open_failed_;
3866 } // namespace
3868 // This is a whitebox test intended to exercise the code path where the on-disk
3869 // directory load code decides to delete the current directory and start fresh.
3871 // This is considered "minor" corruption because the database recreation is
3872 // expected to succeed. The alternative, where recreation does not succeed (ie.
3873 // due to read-only file system), is not tested here.
3874 TEST_F(DirectoryBackingStoreTest, MinorCorruption) {
3876 scoped_ptr<OnDiskDirectoryBackingStore> dbs(
3877 new OnDiskDirectoryBackingStore(GetUsername(), GetDatabasePath()));
3878 EXPECT_TRUE(LoadAndIgnoreReturnedData(dbs.get()));
3881 // Corrupt the root node.
3883 sql::Connection connection;
3884 ASSERT_TRUE(connection.Open(GetDatabasePath()));
3885 ASSERT_TRUE(connection.Execute(
3886 "UPDATE metas SET parent_id='bogus' WHERE id = 'r';"));
3890 scoped_ptr<OnDiskDirectoryBackingStoreForTest> dbs(
3891 new OnDiskDirectoryBackingStoreForTest(GetUsername(),
3892 GetDatabasePath()));
3894 EXPECT_TRUE(LoadAndIgnoreReturnedData(dbs.get()));
3895 EXPECT_TRUE(dbs->DidFailFirstOpenAttempt());
3899 TEST_F(DirectoryBackingStoreTest, DeleteEntries) {
3900 sql::Connection connection;
3901 ASSERT_TRUE(connection.OpenInMemory());
3903 SetUpCurrentDatabaseAndCheckVersion(&connection);
3904 scoped_ptr<TestDirectoryBackingStore> dbs(
3905 new TestDirectoryBackingStore(GetUsername(), &connection));
3906 Directory::MetahandlesMap handles_map;
3907 JournalIndex delete_journals;
3908 Directory::KernelLoadInfo kernel_load_info;
3909 STLValueDeleter<Directory::MetahandlesMap> index_deleter(&handles_map);
3911 dbs->Load(&handles_map, &delete_journals, &kernel_load_info);
3912 size_t initial_size = handles_map.size();
3913 ASSERT_LT(0U, initial_size) << "Test requires handles_map to delete.";
3914 int64 first_to_die = handles_map.begin()->second->ref(META_HANDLE);
3915 MetahandleSet to_delete;
3916 to_delete.insert(first_to_die);
3917 EXPECT_TRUE(dbs->DeleteEntries(TestDirectoryBackingStore::METAS_TABLE,
3918 to_delete));
3920 STLDeleteValues(&handles_map);
3921 dbs->LoadEntries(&handles_map);
3923 EXPECT_EQ(initial_size - 1, handles_map.size());
3924 bool delete_failed = false;
3925 for (Directory::MetahandlesMap::iterator it = handles_map.begin();
3926 it != handles_map.end(); ++it) {
3927 if (it->first == first_to_die) {
3928 delete_failed = true;
3929 break;
3932 EXPECT_FALSE(delete_failed);
3934 to_delete.clear();
3935 for (Directory::MetahandlesMap::iterator it = handles_map.begin();
3936 it != handles_map.end(); ++it) {
3937 to_delete.insert(it->first);
3940 EXPECT_TRUE(dbs->DeleteEntries(TestDirectoryBackingStore::METAS_TABLE,
3941 to_delete));
3943 STLDeleteValues(&handles_map);
3944 dbs->LoadEntries(&handles_map);
3945 EXPECT_EQ(0U, handles_map.size());
3948 TEST_F(DirectoryBackingStoreTest, GenerateCacheGUID) {
3949 const std::string& guid1 = TestDirectoryBackingStore::GenerateCacheGUID();
3950 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID();
3951 EXPECT_EQ(24U, guid1.size());
3952 EXPECT_EQ(24U, guid2.size());
3953 // In theory this test can fail, but it won't before the universe
3954 // dies of heat death.
3955 EXPECT_NE(guid1, guid2);
3958 } // namespace syncable
3959 } // namespace syncer