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"
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/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"
31 SYNC_EXPORT_PRIVATE
extern const int32 kCurrentDBVersion
;
33 class MigrationTest
: public testing::TestWithParam
<int> {
35 virtual void SetUp() {
36 ASSERT_TRUE(temp_dir_
.CreateUniqueTempDir());
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 MetahandlesIndex metas
;
50 JournalIndex delete_journals
;;
51 STLElementDeleter
<MetahandlesIndex
> index_deleter(&metas
);
52 Directory::KernelLoadInfo kernel_load_info
;
53 return dbs
->Load(&metas
, &delete_journals
, &kernel_load_info
) == OPENED
;
56 void SetUpVersion67Database(sql::Connection
* connection
);
57 void SetUpVersion68Database(sql::Connection
* connection
);
58 void SetUpVersion69Database(sql::Connection
* connection
);
59 void SetUpVersion70Database(sql::Connection
* connection
);
60 void SetUpVersion71Database(sql::Connection
* connection
);
61 void SetUpVersion72Database(sql::Connection
* connection
);
62 void SetUpVersion73Database(sql::Connection
* connection
);
63 void SetUpVersion74Database(sql::Connection
* connection
);
64 void SetUpVersion75Database(sql::Connection
* connection
);
65 void SetUpVersion76Database(sql::Connection
* connection
);
66 void SetUpVersion77Database(sql::Connection
* connection
);
67 void SetUpVersion78Database(sql::Connection
* connection
);
68 void SetUpVersion79Database(sql::Connection
* connection
);
69 void SetUpVersion80Database(sql::Connection
* connection
);
70 void SetUpVersion81Database(sql::Connection
* connection
);
71 void SetUpVersion82Database(sql::Connection
* connection
);
72 void SetUpVersion83Database(sql::Connection
* connection
);
73 void SetUpVersion84Database(sql::Connection
* connection
);
74 void SetUpVersion85Database(sql::Connection
* connection
);
75 void SetUpVersion86Database(sql::Connection
* connection
);
77 void SetUpCurrentDatabaseAndCheckVersion(sql::Connection
* connection
) {
78 SetUpVersion86Database(connection
); // Prepopulates data.
79 scoped_ptr
<TestDirectoryBackingStore
> dbs(
80 new TestDirectoryBackingStore(GetUsername(), connection
));
81 ASSERT_EQ(kCurrentDBVersion
, dbs
->GetVersion());
83 ASSERT_TRUE(LoadAndIgnoreReturnedData(dbs
.get()));
84 ASSERT_FALSE(dbs
->needs_column_refresh_
);
88 base::ScopedTempDir temp_dir_
;
91 class DirectoryBackingStoreTest
: public MigrationTest
{};
95 // On Windows, we used to store timestamps in FILETIME format.
96 #define LEGACY_META_PROTO_TIMES_1 129079956640320000LL
97 #define LEGACY_META_PROTO_TIMES_2 128976886618480000LL
98 #define LEGACY_META_PROTO_TIMES_4 129002163642690000LL
99 #define LEGACY_META_PROTO_TIMES_5 129001555500000000LL
100 #define LEGACY_META_PROTO_TIMES_6 129053976170000000LL
101 #define LEGACY_META_PROTO_TIMES_7 128976864758480000LL
102 #define LEGACY_META_PROTO_TIMES_8 128976864758480000LL
103 #define LEGACY_META_PROTO_TIMES_9 128976864758480000LL
104 #define LEGACY_META_PROTO_TIMES_10 128976864758480000LL
105 #define LEGACY_META_PROTO_TIMES_11 129079956948440000LL
106 #define LEGACY_META_PROTO_TIMES_12 129079957513650000LL
107 #define LEGACY_META_PROTO_TIMES_13 129079957985300000LL
108 #define LEGACY_META_PROTO_TIMES_14 129079958383000000LL
110 #define LEGACY_META_PROTO_TIMES_STR_1 "129079956640320000"
111 #define LEGACY_META_PROTO_TIMES_STR_2 "128976886618480000"
112 #define LEGACY_META_PROTO_TIMES_STR_4 "129002163642690000"
113 #define LEGACY_META_PROTO_TIMES_STR_5 "129001555500000000"
114 #define LEGACY_META_PROTO_TIMES_STR_6 "129053976170000000"
115 #define LEGACY_META_PROTO_TIMES_STR_7 "128976864758480000"
116 #define LEGACY_META_PROTO_TIMES_STR_8 "128976864758480000"
117 #define LEGACY_META_PROTO_TIMES_STR_9 "128976864758480000"
118 #define LEGACY_META_PROTO_TIMES_STR_10 "128976864758480000"
119 #define LEGACY_META_PROTO_TIMES_STR_11 "129079956948440000"
120 #define LEGACY_META_PROTO_TIMES_STR_12 "129079957513650000"
121 #define LEGACY_META_PROTO_TIMES_STR_13 "129079957985300000"
122 #define LEGACY_META_PROTO_TIMES_STR_14 "129079958383000000"
126 // ruby -ane '$F[1].sub!("LEGACY_", ""); $F[2] = Integer($F[2].sub!("LL", "")) /
127 // 10000 - 11644473600000; print "#{$F[0]} #{$F[1]} #{$F[2]}LL"'
129 // Magic numbers taken from
130 // http://stackoverflow.com/questions/5398557/
131 // java-library-for-dealing-with-win32-filetime .
133 // Now we store them in Java format (ms since the Unix epoch).
134 #define META_PROTO_TIMES_1 1263522064032LL
135 #define META_PROTO_TIMES_2 1253215061848LL
136 #define META_PROTO_TIMES_4 1255742764269LL
137 #define META_PROTO_TIMES_5 1255681950000LL
138 #define META_PROTO_TIMES_6 1260924017000LL
139 #define META_PROTO_TIMES_7 1253212875848LL
140 #define META_PROTO_TIMES_8 1253212875848LL
141 #define META_PROTO_TIMES_9 1253212875848LL
142 #define META_PROTO_TIMES_10 1253212875848LL
143 #define META_PROTO_TIMES_11 1263522094844LL
144 #define META_PROTO_TIMES_12 1263522151365LL
145 #define META_PROTO_TIMES_13 1263522198530LL
146 #define META_PROTO_TIMES_14 1263522238300LL
148 #define META_PROTO_TIMES_STR_1 "1263522064032"
149 #define META_PROTO_TIMES_STR_2 "1253215061848"
150 #define META_PROTO_TIMES_STR_4 "1255742764269"
151 #define META_PROTO_TIMES_STR_5 "1255681950000"
152 #define META_PROTO_TIMES_STR_6 "1260924017000"
153 #define META_PROTO_TIMES_STR_7 "1253212875848"
154 #define META_PROTO_TIMES_STR_8 "1253212875848"
155 #define META_PROTO_TIMES_STR_9 "1253212875848"
156 #define META_PROTO_TIMES_STR_10 "1253212875848"
157 #define META_PROTO_TIMES_STR_11 "1263522094844"
158 #define META_PROTO_TIMES_STR_12 "1263522151365"
159 #define META_PROTO_TIMES_STR_13 "1263522198530"
160 #define META_PROTO_TIMES_STR_14 "1263522238300"
164 // On other platforms, we used to store timestamps in time_t format (s
165 // since the Unix epoch).
166 #define LEGACY_META_PROTO_TIMES_1 1263522064LL
167 #define LEGACY_META_PROTO_TIMES_2 1253215061LL
168 #define LEGACY_META_PROTO_TIMES_4 1255742764LL
169 #define LEGACY_META_PROTO_TIMES_5 1255681950LL
170 #define LEGACY_META_PROTO_TIMES_6 1260924017LL
171 #define LEGACY_META_PROTO_TIMES_7 1253212875LL
172 #define LEGACY_META_PROTO_TIMES_8 1253212875LL
173 #define LEGACY_META_PROTO_TIMES_9 1253212875LL
174 #define LEGACY_META_PROTO_TIMES_10 1253212875LL
175 #define LEGACY_META_PROTO_TIMES_11 1263522094LL
176 #define LEGACY_META_PROTO_TIMES_12 1263522151LL
177 #define LEGACY_META_PROTO_TIMES_13 1263522198LL
178 #define LEGACY_META_PROTO_TIMES_14 1263522238LL
180 #define LEGACY_META_PROTO_TIMES_STR_1 "1263522064"
181 #define LEGACY_META_PROTO_TIMES_STR_2 "1253215061"
182 #define LEGACY_META_PROTO_TIMES_STR_4 "1255742764"
183 #define LEGACY_META_PROTO_TIMES_STR_5 "1255681950"
184 #define LEGACY_META_PROTO_TIMES_STR_6 "1260924017"
185 #define LEGACY_META_PROTO_TIMES_STR_7 "1253212875"
186 #define LEGACY_META_PROTO_TIMES_STR_8 "1253212875"
187 #define LEGACY_META_PROTO_TIMES_STR_9 "1253212875"
188 #define LEGACY_META_PROTO_TIMES_STR_10 "1253212875"
189 #define LEGACY_META_PROTO_TIMES_STR_11 "1263522094"
190 #define LEGACY_META_PROTO_TIMES_STR_12 "1263522151"
191 #define LEGACY_META_PROTO_TIMES_STR_13 "1263522198"
192 #define LEGACY_META_PROTO_TIMES_STR_14 "1263522238"
194 // Now we store them in Java format (ms since the Unix epoch).
195 #define META_PROTO_TIMES_1 1263522064000LL
196 #define META_PROTO_TIMES_2 1253215061000LL
197 #define META_PROTO_TIMES_4 1255742764000LL
198 #define META_PROTO_TIMES_5 1255681950000LL
199 #define META_PROTO_TIMES_6 1260924017000LL
200 #define META_PROTO_TIMES_7 1253212875000LL
201 #define META_PROTO_TIMES_8 1253212875000LL
202 #define META_PROTO_TIMES_9 1253212875000LL
203 #define META_PROTO_TIMES_10 1253212875000LL
204 #define META_PROTO_TIMES_11 1263522094000LL
205 #define META_PROTO_TIMES_12 1263522151000LL
206 #define META_PROTO_TIMES_13 1263522198000LL
207 #define META_PROTO_TIMES_14 1263522238000LL
209 #define META_PROTO_TIMES_STR_1 "1263522064000"
210 #define META_PROTO_TIMES_STR_2 "1253215061000"
211 #define META_PROTO_TIMES_STR_4 "1255742764000"
212 #define META_PROTO_TIMES_STR_5 "1255681950000"
213 #define META_PROTO_TIMES_STR_6 "1260924017000"
214 #define META_PROTO_TIMES_STR_7 "1253212875000"
215 #define META_PROTO_TIMES_STR_8 "1253212875000"
216 #define META_PROTO_TIMES_STR_9 "1253212875000"
217 #define META_PROTO_TIMES_STR_10 "1253212875000"
218 #define META_PROTO_TIMES_STR_11 "1263522094000"
219 #define META_PROTO_TIMES_STR_12 "1263522151000"
220 #define META_PROTO_TIMES_STR_13 "1263522198000"
221 #define META_PROTO_TIMES_STR_14 "1263522238000"
225 // Helper macros for the database dumps in the SetUpVersion*Database
227 #define LEGACY_META_PROTO_TIMES(x) LEGACY_META_PROTO_TIMES_##x
228 #define LEGACY_META_PROTO_TIMES_STR(x) LEGACY_META_PROTO_TIMES_STR_##x
229 #define LEGACY_PROTO_TIME_VALS(x) \
230 LEGACY_META_PROTO_TIMES_STR(x) "," \
231 LEGACY_META_PROTO_TIMES_STR(x) "," \
232 LEGACY_META_PROTO_TIMES_STR(x) "," \
233 LEGACY_META_PROTO_TIMES_STR(x)
234 #define META_PROTO_TIMES(x) META_PROTO_TIMES_##x
235 #define META_PROTO_TIMES_STR(x) META_PROTO_TIMES_STR_##x
236 #define META_PROTO_TIMES_VALS(x) \
237 META_PROTO_TIMES_STR(x) "," \
238 META_PROTO_TIMES_STR(x) "," \
239 META_PROTO_TIMES_STR(x) "," \
240 META_PROTO_TIMES_STR(x)
244 // Helper functions for testing.
246 enum ShouldIncludeDeletedItems
{
247 INCLUDE_DELETED_ITEMS
,
248 DONT_INCLUDE_DELETED_ITEMS
251 // Returns a map from metahandle -> expected legacy time (in proto
253 std::map
<int64
, int64
> GetExpectedLegacyMetaProtoTimes(
254 enum ShouldIncludeDeletedItems include_deleted
) {
255 std::map
<int64
, int64
> expected_legacy_meta_proto_times
;
256 expected_legacy_meta_proto_times
[1] = LEGACY_META_PROTO_TIMES(1);
257 if (include_deleted
== INCLUDE_DELETED_ITEMS
) {
258 expected_legacy_meta_proto_times
[2] = LEGACY_META_PROTO_TIMES(2);
259 expected_legacy_meta_proto_times
[4] = LEGACY_META_PROTO_TIMES(4);
260 expected_legacy_meta_proto_times
[5] = LEGACY_META_PROTO_TIMES(5);
262 expected_legacy_meta_proto_times
[6] = LEGACY_META_PROTO_TIMES(6);
263 expected_legacy_meta_proto_times
[7] = LEGACY_META_PROTO_TIMES(7);
264 expected_legacy_meta_proto_times
[8] = LEGACY_META_PROTO_TIMES(8);
265 expected_legacy_meta_proto_times
[9] = LEGACY_META_PROTO_TIMES(9);
266 expected_legacy_meta_proto_times
[10] = LEGACY_META_PROTO_TIMES(10);
267 expected_legacy_meta_proto_times
[11] = LEGACY_META_PROTO_TIMES(11);
268 expected_legacy_meta_proto_times
[12] = LEGACY_META_PROTO_TIMES(12);
269 expected_legacy_meta_proto_times
[13] = LEGACY_META_PROTO_TIMES(13);
270 expected_legacy_meta_proto_times
[14] = LEGACY_META_PROTO_TIMES(14);
271 return expected_legacy_meta_proto_times
;
274 // Returns a map from metahandle -> expected time (in proto format).
275 std::map
<int64
, int64
> GetExpectedMetaProtoTimes(
276 enum ShouldIncludeDeletedItems include_deleted
) {
277 std::map
<int64
, int64
> expected_meta_proto_times
;
278 expected_meta_proto_times
[1] = META_PROTO_TIMES(1);
279 if (include_deleted
== INCLUDE_DELETED_ITEMS
) {
280 expected_meta_proto_times
[2] = META_PROTO_TIMES(2);
281 expected_meta_proto_times
[4] = META_PROTO_TIMES(4);
282 expected_meta_proto_times
[5] = META_PROTO_TIMES(5);
284 expected_meta_proto_times
[6] = META_PROTO_TIMES(6);
285 expected_meta_proto_times
[7] = META_PROTO_TIMES(7);
286 expected_meta_proto_times
[8] = META_PROTO_TIMES(8);
287 expected_meta_proto_times
[9] = META_PROTO_TIMES(9);
288 expected_meta_proto_times
[10] = META_PROTO_TIMES(10);
289 expected_meta_proto_times
[11] = META_PROTO_TIMES(11);
290 expected_meta_proto_times
[12] = META_PROTO_TIMES(12);
291 expected_meta_proto_times
[13] = META_PROTO_TIMES(13);
292 expected_meta_proto_times
[14] = META_PROTO_TIMES(14);
293 return expected_meta_proto_times
;
296 // Returns a map from metahandle -> expected time (as a Time object).
297 std::map
<int64
, base::Time
> GetExpectedMetaTimes() {
298 std::map
<int64
, base::Time
> expected_meta_times
;
299 const std::map
<int64
, int64
>& expected_meta_proto_times
=
300 GetExpectedMetaProtoTimes(INCLUDE_DELETED_ITEMS
);
301 for (std::map
<int64
, int64
>::const_iterator it
=
302 expected_meta_proto_times
.begin();
303 it
!= expected_meta_proto_times
.end(); ++it
) {
304 expected_meta_times
[it
->first
] = ProtoTimeToTime(it
->second
);
306 return expected_meta_times
;
309 // Extracts a map from metahandle -> time (in proto format) from the
311 std::map
<int64
, int64
> GetMetaProtoTimes(sql::Connection
*db
) {
312 sql::Statement
s(db
->GetCachedStatement(
314 "SELECT metahandle, mtime, server_mtime, ctime, server_ctime "
316 EXPECT_EQ(5, s
.ColumnCount());
317 std::map
<int64
, int64
> meta_times
;
319 int64 metahandle
= s
.ColumnInt64(0);
320 int64 mtime
= s
.ColumnInt64(1);
321 int64 server_mtime
= s
.ColumnInt64(2);
322 int64 ctime
= s
.ColumnInt64(3);
323 int64 server_ctime
= s
.ColumnInt64(4);
324 EXPECT_EQ(mtime
, server_mtime
);
325 EXPECT_EQ(mtime
, ctime
);
326 EXPECT_EQ(mtime
, server_ctime
);
327 meta_times
[metahandle
] = mtime
;
329 EXPECT_TRUE(s
.Succeeded());
333 ::testing::AssertionResult
AssertTimesMatch(const char* t1_expr
,
335 const base::Time
& t1
,
336 const base::Time
& t2
) {
338 return ::testing::AssertionSuccess();
340 return ::testing::AssertionFailure()
341 << t1_expr
<< " and " << t2_expr
342 << " (internal values: " << t1
.ToInternalValue()
343 << " and " << t2
.ToInternalValue()
344 << ") (proto time: " << TimeToProtoTime(t1
)
345 << " and " << TimeToProtoTime(t2
)
349 // Expect that all time fields of the given entry kernel will be the
351 void ExpectTime(const EntryKernel
& entry_kernel
,
352 const base::Time
& expected_time
) {
353 EXPECT_PRED_FORMAT2(AssertTimesMatch
,
354 expected_time
, entry_kernel
.ref(CTIME
));
355 EXPECT_PRED_FORMAT2(AssertTimesMatch
,
356 expected_time
, entry_kernel
.ref(SERVER_CTIME
));
357 EXPECT_PRED_FORMAT2(AssertTimesMatch
,
358 expected_time
, entry_kernel
.ref(MTIME
));
359 EXPECT_PRED_FORMAT2(AssertTimesMatch
,
360 expected_time
, entry_kernel
.ref(SERVER_MTIME
));
363 // Expect that all the entries in |index| have times matching those in
364 // the given map (from metahandle to expect time).
365 void ExpectTimes(const MetahandlesIndex
& index
,
366 const std::map
<int64
, base::Time
>& expected_times
) {
367 for (MetahandlesIndex::const_iterator it
= index
.begin();
368 it
!= index
.end(); ++it
) {
369 int64 meta_handle
= (*it
)->ref(META_HANDLE
);
370 SCOPED_TRACE(meta_handle
);
371 std::map
<int64
, base::Time
>::const_iterator it2
=
372 expected_times
.find(meta_handle
);
373 if (it2
== expected_times
.end()) {
374 ADD_FAILURE() << "Could not find expected time for " << meta_handle
;
377 ExpectTime(**it
, it2
->second
);
383 void MigrationTest::SetUpVersion67Database(sql::Connection
* connection
) {
384 // This is a version 67 database dump whose contents were backformed from
385 // the contents of the version 68 database dump (the v68 migration was
386 // actually written first).
387 ASSERT_TRUE(connection
->is_open());
388 ASSERT_TRUE(connection
->BeginTransaction());
389 ASSERT_TRUE(connection
->Execute(
390 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
391 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
392 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL,"
393 "base_version bigint default -1,server_version bigint default 0,"
394 "mtime bigint default 0,server_mtime bigint default 0,"
395 "ctime bigint default 0,server_ctime bigint default 0,"
396 "server_position_in_parent bigint default 0,"
397 "local_external_id bigint default 0,id varchar(255) default 'r',"
398 "parent_id varchar(255) default 'r',"
399 "server_parent_id varchar(255) default 'r',"
400 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
401 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
402 "is_del bit default 0,is_dir bit default 0,"
403 "is_bookmark_object bit default 0,server_is_dir bit default 0,"
404 "server_is_del bit default 0,server_is_bookmark_object bit default 0,"
405 "name varchar(255), " /* COLLATE PATHNAME, */
406 "unsanitized_name varchar(255)," /* COLLATE PATHNAME, */
407 "non_unique_name varchar,"
408 "server_name varchar(255)," /* COLLATE PATHNAME */
409 "server_non_unique_name varchar,"
410 "bookmark_url varchar,server_bookmark_url varchar,"
411 "singleton_tag varchar,bookmark_favicon blob,"
412 "server_bookmark_favicon blob);"
413 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
414 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,"
415 "NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);"
416 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
418 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"
419 "'Deleted Item',NULL,'Deleted Item','Deleted Item','Deleted Item',"
420 "'http://www.google.com/','http://www.google.com/2',NULL,'AASGASGA',"
422 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
424 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"
425 "'Welcome to Chromium',NULL,'Welcome to Chromium',"
426 "'Welcome to Chromium','Welcome to Chromium',"
427 "'http://www.google.com/chrome/intl/en/welcome.html',"
428 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,"
430 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
432 "7,'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"
433 "'Google',NULL,'Google','Google','Google','http://www.google.com/',"
434 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG');"
435 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
437 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,"
438 "'The Internet',NULL,'The Internet','The Internet',"
439 "'The Internet',NULL,NULL,NULL,NULL,NULL);"
440 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
442 "1048576,0,'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,"
443 "'Google Chrome',NULL,'Google Chrome','Google Chrome',"
444 "'Google Chrome',NULL,NULL,'google_chrome',NULL,NULL);"
445 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
447 "0,'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"
448 "NULL,'Bookmarks','Bookmarks','Bookmarks',NULL,NULL,"
449 "'google_chrome_bookmarks',NULL,NULL);"
450 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
452 "1048576,1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,"
453 "1,'Bookmark Bar',NULL,'Bookmark Bar','Bookmark Bar','Bookmark Bar',"
454 "NULL,NULL,'bookmark_bar',NULL,NULL);"
455 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
457 "2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"
458 "'Other Bookmarks',NULL,'Other Bookmarks','Other Bookmarks',"
459 "'Other Bookmarks',NULL,NULL,'other_bookmarks',"
461 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
463 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"
464 "'Home (The Chromium Projects)',NULL,'Home (The Chromium Projects)',"
465 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
466 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"
467 "'AGATWA','AFAGVASF');"
468 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
470 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"
471 "'Extra Bookmarks',NULL,'Extra Bookmarks','Extra Bookmarks',"
472 "'Extra Bookmarks',NULL,NULL,NULL,NULL,NULL);"
473 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
475 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"
476 "1,'ICANN | Internet Corporation for Assigned Names and Numbers',"
477 "'ICANN Internet Corporation for Assigned Names and Numbers',"
478 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
479 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
480 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
481 "'http://www.icann.com/','http://www.icann.com/',NULL,"
482 "'PNGAXF0AAFF','DAAFASF');"
483 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
485 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"
486 "'The WebKit Open Source Project',NULL,"
487 "'The WebKit Open Source Project','The WebKit Open Source Project',"
488 "'The WebKit Open Source Project','http://webkit.org/',"
489 "'http://webkit.org/x',NULL,'PNGX','PNG2Y');"
490 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
491 "last_sync_timestamp INT, name VARCHAR(128), "
492 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
493 "db_create_version VARCHAR(128), db_create_time int, "
494 "next_id bigint default -2, cache_guid VARCHAR(32));"
495 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
496 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
497 "'Unknown',1263522064,-65542,"
498 "'9010788312004066376x-6609234393368420856x');"
499 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
500 "INSERT INTO share_version VALUES('nick@chromium.org',68);"));
501 ASSERT_TRUE(connection
->CommitTransaction());
504 void MigrationTest::SetUpVersion68Database(sql::Connection
* connection
) {
505 // This sets up an actual version 68 database dump. The IDs were
506 // canonicalized to be less huge, and the favicons were overwritten
507 // with random junk so that they didn't contain any unprintable
508 // characters. A few server URLs were tweaked so that they'd be
509 // different from the local URLs. Lastly, the custom collation on
510 // the server_non_unique_name column was removed.
511 ASSERT_TRUE(connection
->is_open());
512 ASSERT_TRUE(connection
->BeginTransaction());
513 ASSERT_TRUE(connection
->Execute(
514 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
515 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
516 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL,"
517 "base_version bigint default -1,server_version bigint default 0,"
518 "mtime bigint default 0,server_mtime bigint default 0,"
519 "ctime bigint default 0,server_ctime bigint default 0,"
520 "server_position_in_parent bigint default 0,"
521 "local_external_id bigint default 0,id varchar(255) default 'r',"
522 "parent_id varchar(255) default 'r',"
523 "server_parent_id varchar(255) default 'r',"
524 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
525 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
526 "is_del bit default 0,is_dir bit default 0,"
527 "is_bookmark_object bit default 0,server_is_dir bit default 0,"
528 "server_is_del bit default 0,"
529 "server_is_bookmark_object bit default 0,"
530 "non_unique_name varchar,server_non_unique_name varchar(255),"
531 "bookmark_url varchar,server_bookmark_url varchar,"
532 "singleton_tag varchar,bookmark_favicon blob,"
533 "server_bookmark_favicon blob);"
534 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
535 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,"
536 "NULL,NULL,NULL,NULL,NULL,NULL);"
537 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
539 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"
540 "'Deleted Item','Deleted Item','http://www.google.com/',"
541 "'http://www.google.com/2',NULL,'AASGASGA','ASADGADGADG');"
542 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
544 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"
545 "'Welcome to Chromium','Welcome to Chromium',"
546 "'http://www.google.com/chrome/intl/en/welcome.html',"
547 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,"
549 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
551 "7,'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"
552 "'Google','Google','http://www.google.com/',"
553 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG');"
554 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
556 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,"
557 "'The Internet','The Internet',NULL,NULL,NULL,NULL,NULL);"
558 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
560 "1048576,0,'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,"
561 "'Google Chrome','Google Chrome',NULL,NULL,'google_chrome',NULL,"
563 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
565 "0,'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"
566 "'Bookmarks',NULL,NULL,'google_chrome_bookmarks',NULL,NULL);"
567 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
569 "1048576,1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,"
570 "1,'Bookmark Bar','Bookmark Bar',NULL,NULL,'bookmark_bar',NULL,"
572 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
574 "2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"
575 "'Other Bookmarks','Other Bookmarks',NULL,NULL,'other_bookmarks',"
577 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
579 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"
580 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
581 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"
582 "'AGATWA','AFAGVASF');"
583 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
585 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"
586 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,NULL,NULL,NULL);"
587 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
589 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"
590 "1,'ICANN | Internet Corporation for Assigned Names and Numbers',"
591 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
592 "'http://www.icann.com/','http://www.icann.com/',NULL,"
593 "'PNGAXF0AAFF','DAAFASF');"
594 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
596 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"
597 "'The WebKit Open Source Project','The WebKit Open Source Project',"
598 "'http://webkit.org/','http://webkit.org/x',NULL,'PNGX','PNG2Y');"
599 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
600 "last_sync_timestamp INT, name VARCHAR(128), "
601 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
602 "db_create_version VARCHAR(128), db_create_time int, "
603 "next_id bigint default -2, cache_guid VARCHAR(32));"
604 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
605 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
606 "'Unknown',1263522064,-65542,"
607 "'9010788312004066376x-6609234393368420856x');"
608 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
609 "INSERT INTO share_version VALUES('nick@chromium.org',68);"));
610 ASSERT_TRUE(connection
->CommitTransaction());
613 void MigrationTest::SetUpVersion69Database(sql::Connection
* connection
) {
614 ASSERT_TRUE(connection
->is_open());
615 ASSERT_TRUE(connection
->BeginTransaction());
616 ASSERT_TRUE(connection
->Execute(
617 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
618 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
619 "CREATE TABLE metas (metahandle bigint primary key ON CONFLICT FAIL,"
620 "base_version bigint default -1,server_version bigint default 0,"
621 "mtime bigint default 0,server_mtime bigint default 0,"
622 "ctime bigint default 0,server_ctime bigint default 0,"
623 "server_position_in_parent bigint default 0,"
624 "local_external_id bigint default 0,id varchar(255) default 'r',"
625 "parent_id varchar(255) default 'r',"
626 "server_parent_id varchar(255) default 'r',"
627 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
628 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
629 "is_del bit default 0,is_dir bit default 0,"
630 "is_bookmark_object bit default 0,server_is_dir bit default 0,"
631 "server_is_del bit default 0,"
632 "server_is_bookmark_object bit default 0,"
633 "non_unique_name varchar,server_non_unique_name varchar(255),"
634 "bookmark_url varchar,server_bookmark_url varchar,"
635 "singleton_tag varchar,bookmark_favicon blob,"
636 "server_bookmark_favicon blob, specifics blob, "
637 "server_specifics blob);"
638 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
639 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,0,0,NULL,NULL,NULL,NULL,NULL,"
640 "NULL,NULL,X'',X'');"
641 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
643 "4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,1,0,1,1,"
644 "'Deleted Item','Deleted Item','http://www.google.com/',"
645 "'http://www.google.com/2',NULL,'AASGASGA','ASADGADGADG',"
646 "X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F120841415"
647 "34741534741',X'C28810260A17687474703A2F2F7777772E676F6F676C652E636F"
648 "6D2F32120B4153414447414447414447');"
649 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
651 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,1,0,1,1,"
652 "'Welcome to Chromium','Welcome to Chromium',"
653 "'http://www.google.com/chrome/intl/en/welcome.html',"
654 "'http://www.google.com/chrome/intl/en/welcome.html',NULL,NULL,NULL,"
655 "X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
656 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A3168"
657 "7474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F6"
658 "56E2F77656C636F6D652E68746D6C1200');"
659 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
661 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,1,0,1,1,"
662 "'Google','Google','http://www.google.com/',"
663 "'http://www.google.com/',NULL,'AGASGASG','AGFDGASG',X'C28810220A166"
664 "87474703A2F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'"
665 "C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464"
667 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
669 ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,1,0,1,'The Internet',"
670 "'The Internet',NULL,NULL,NULL,NULL,NULL,X'C2881000',X'C2881000');"
671 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
673 "'s_ID_7','r','r','r','r',0,0,0,1,1,1,0,1,'Google Chrome',"
674 "'Google Chrome',NULL,NULL,'google_chrome',NULL,NULL,NULL,NULL);"
675 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
677 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,1,0,1,'Bookmarks',"
678 "'Bookmarks',NULL,NULL,'google_chrome_bookmarks',NULL,NULL,"
679 "X'C2881000',X'C2881000');"
680 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
682 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,1,0,1,"
683 "'Bookmark Bar','Bookmark Bar',NULL,NULL,'bookmark_bar',NULL,NULL,"
684 "X'C2881000',X'C2881000');"
685 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
687 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,1,0,1,"
688 "'Other Bookmarks','Other Bookmarks',NULL,NULL,'other_bookmarks',"
689 "NULL,NULL,X'C2881000',X'C2881000');"
690 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
692 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,1,0,0,1,"
693 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
694 "'http://dev.chromium.org/','http://dev.chromium.org/other',NULL,"
695 "'AGATWA','AFAGVASF',X'C28810220A18687474703A2F2F6465762E6368726F6D6"
696 "9756D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F646576"
697 "2E6368726F6D69756D2E6F72672F6F7468657212084146414756415346');"
698 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
700 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,1,0,1,"
701 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,NULL,NULL,NULL,"
702 "X'C2881000',X'C2881000');"
703 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
705 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,1,0,0,"
706 "1,'ICANN | Internet Corporation for Assigned Names and Numbers',"
707 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
708 "'http://www.icann.com/','http://www.icann.com/',NULL,'PNGAXF0AAFF',"
709 "'DAAFASF',X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F1"
710 "20B504E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963"
711 "616E6E2E636F6D2F120744414146415346');"
712 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
714 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,1,0,0,1,"
715 "'The WebKit Open Source Project','The WebKit Open Source Project',"
716 "'http://webkit.org/','http://webkit.org/x',NULL,'PNGX','PNG2Y',"
717 "X'C288101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C2"
718 "88101C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259');"
719 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
720 "last_sync_timestamp INT, name VARCHAR(128), "
721 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
722 "db_create_version VARCHAR(128), db_create_time int, "
723 "next_id bigint default -2, cache_guid VARCHAR(32));"
724 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
725 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
726 "'Unknown',1263522064,-65542,"
727 "'9010788312004066376x-6609234393368420856x');"
728 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
729 "INSERT INTO share_version VALUES('nick@chromium.org',69);"
731 ASSERT_TRUE(connection
->CommitTransaction());
734 void MigrationTest::SetUpVersion70Database(sql::Connection
* connection
) {
735 ASSERT_TRUE(connection
->is_open());
736 ASSERT_TRUE(connection
->BeginTransaction());
737 ASSERT_TRUE(connection
->Execute(
738 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
739 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
740 "CREATE TABLE share_info (id VARCHAR(128) primary key, "
741 "last_sync_timestamp INT, name VARCHAR(128), "
742 "initial_sync_ended BIT default 0, store_birthday VARCHAR(256), "
743 "db_create_version VARCHAR(128), db_create_time int, "
744 "next_id bigint default -2, cache_guid VARCHAR(32));"
745 "INSERT INTO share_info VALUES('nick@chromium.org',694,"
746 "'nick@chromium.org',1,'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb',"
747 "'Unknown',1263522064,-65542,"
748 "'9010788312004066376x-6609234393368420856x');"
749 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
750 "INSERT INTO share_version VALUES('nick@chromium.org',70);"
751 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
752 "base_version bigint default -1,server_version bigint default 0,"
753 "mtime bigint default 0,server_mtime bigint default 0,"
754 "ctime bigint default 0,server_ctime bigint default 0,"
755 "server_position_in_parent bigint default 0,"
756 "local_external_id bigint default 0,id varchar(255) default 'r',"
757 "parent_id varchar(255) default 'r',"
758 "server_parent_id varchar(255) default 'r',"
759 "prev_id varchar(255) default 'r',next_id varchar(255) default 'r',"
760 "is_unsynced bit default 0,is_unapplied_update bit default 0,"
761 "is_del bit default 0,is_dir bit default 0,"
762 "server_is_dir bit default 0,server_is_del bit default 0,"
763 "non_unique_name varchar,server_non_unique_name varchar(255),"
764 "unique_server_tag varchar,unique_client_tag varchar,"
765 "specifics blob,server_specifics blob);"
766 "INSERT INTO metas VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
767 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'');"
768 "INSERT INTO metas VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2) ","
769 "-2097152,4,'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,"
770 "1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A"
771 "2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X'C2881026"
772 "0A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B415341444741"
774 "INSERT INTO metas VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
776 "3,'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
777 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A"
778 "31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E74"
779 "6C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F"
780 "2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F7765"
781 "6C636F6D652E68746D6C1200');"
782 "INSERT INTO metas VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
784 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
785 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C6"
786 "52E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F77777"
787 "72E676F6F676C652E636F6D2F12084147464447415347');"
788 "INSERT INTO metas VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
790 "6,'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
791 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
792 "INSERT INTO metas VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
794 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome',"
795 "'Google Chrome','google_chrome',NULL,NULL,NULL);"
796 "INSERT INTO metas VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
798 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
799 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',"
801 "INSERT INTO metas VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
803 "1,'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,"
804 "'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881000',"
806 "INSERT INTO metas VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
808 "2097152,2,'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
809 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
810 "X'C2881000',X'C2881000');"
811 "INSERT INTO metas VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
813 "8,'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
814 "'Home (The Chromium Projects)','Home (The Chromium Projects)',"
815 "NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F"
816 "72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636872"
817 "6F6D69756D2E6F72672F6F7468657212084146414756415346');"
818 "INSERT INTO metas VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
820 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
821 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
823 "INSERT INTO metas VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
825 "10,'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
826 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
827 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
828 "NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F"
829 "120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772E69"
830 "63616E6E2E636F6D2F120744414146415346');"
831 "INSERT INTO metas VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
833 "11,'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
834 "'The WebKit Open Source Project','The WebKit Open Source Project',"
835 "NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
836 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F78120550"
839 ASSERT_TRUE(connection
->CommitTransaction());
842 void MigrationTest::SetUpVersion71Database(sql::Connection
* connection
) {
843 ASSERT_TRUE(connection
->is_open());
844 ASSERT_TRUE(connection
->BeginTransaction());
845 ASSERT_TRUE(connection
->Execute(
846 "CREATE TABLE extended_attributes(metahandle bigint, key varchar(127), "
847 "value blob, PRIMARY KEY(metahandle, key) ON CONFLICT REPLACE);"
848 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
849 "INSERT INTO 'share_version' VALUES('nick@chromium.org',71);"
850 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
851 "base_version bigint default -1,server_version bigint default 0,"
852 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint "
853 "default 0,server_ctime bigint default 0,server_position_in_parent "
854 "bigint default 0,local_external_id bigint default 0,id varchar(255) "
855 "default 'r',parent_id varchar(255) default 'r',server_parent_id "
856 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id "
857 "varchar(255) default 'r',is_unsynced bit default 0,"
858 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit "
859 "default 0,server_is_dir bit default 0,server_is_del bit default 0,"
860 "non_unique_name varchar,server_non_unique_name varchar(255),"
861 "unique_server_tag varchar,unique_client_tag varchar,specifics blob,"
862 "server_specifics blob);"
863 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
864 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"
865 "NULL,NULL,X'',X'');"
866 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
868 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"
869 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"
870 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"
871 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"
873 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
875 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
876 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"
877 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"
878 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"
879 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"
880 "652E68746D6C1200');"
881 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
883 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
884 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"
885 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"
886 "76F6F676C652E636F6D2F12084147464447415347');"
887 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
889 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
890 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
891 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
893 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"
894 ",'google_chrome',NULL,NULL,NULL);"
895 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
897 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
898 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
899 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
901 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"
902 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
903 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
905 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
906 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
907 "X'C2881000',X'C2881000');"
908 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
910 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
911 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"
912 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"
913 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
914 "D2E6F72672F6F7468657212084146414756415346');"
915 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
917 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
918 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
920 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
922 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
923 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
924 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"
925 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
926 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"
927 "E636F6D2F120744414146415346');"
928 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
930 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
931 "'The WebKit Open Source Project','The WebKit Open Source Project',"
932 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
933 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E"
935 "CREATE TABLE models (model_id BLOB primary key, "
936 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);"
937 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
938 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, "
939 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, "
940 "next_id INT default -2, cache_guid TEXT);"
941 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
942 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,"
943 "'9010788312004066376x-6609234393368420856x');"));
944 ASSERT_TRUE(connection
->CommitTransaction());
947 void MigrationTest::SetUpVersion72Database(sql::Connection
* connection
) {
948 ASSERT_TRUE(connection
->is_open());
949 ASSERT_TRUE(connection
->BeginTransaction());
950 ASSERT_TRUE(connection
->Execute(
951 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
952 "INSERT INTO 'share_version' VALUES('nick@chromium.org',72);"
953 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
954 "base_version bigint default -1,server_version bigint default 0,"
955 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint "
956 "default 0,server_ctime bigint default 0,server_position_in_parent "
957 "bigint default 0,local_external_id bigint default 0,id varchar(255) "
958 "default 'r',parent_id varchar(255) default 'r',server_parent_id "
959 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id "
960 "varchar(255) default 'r',is_unsynced bit default 0,"
961 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit "
962 "default 0,server_is_dir bit default 0,server_is_del bit default 0,"
963 "non_unique_name varchar,server_non_unique_name varchar(255),"
964 "unique_server_tag varchar,unique_client_tag varchar,specifics blob,"
965 "server_specifics blob);"
966 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
967 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"
968 "NULL,NULL,X'',X'');"
969 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
971 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"
972 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"
973 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"
974 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"
976 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
978 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
979 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"
980 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"
981 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"
982 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"
983 "652E68746D6C1200');"
984 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
986 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
987 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"
988 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"
989 "76F6F676C652E636F6D2F12084147464447415347');"
990 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
992 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
993 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
994 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
996 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"
997 ",'google_chrome',NULL,NULL,NULL);"
998 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1000 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
1001 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1002 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1004 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"
1005 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1006 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1008 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
1009 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
1010 "X'C2881000',X'C2881000');"
1011 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1013 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
1014 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"
1015 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"
1016 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
1017 "D2E6F72672F6F7468657212084146414756415346');"
1018 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1020 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
1021 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
1023 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1025 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
1026 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
1027 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"
1028 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
1029 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"
1030 "E636F6D2F120744414146415346');"
1031 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1033 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
1034 "'The WebKit Open Source Project','The WebKit Open Source Project',"
1035 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
1036 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E"
1038 "CREATE TABLE models (model_id BLOB primary key, "
1039 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);"
1040 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
1041 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, "
1042 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, "
1043 "next_id INT default -2, cache_guid TEXT);"
1044 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1045 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,"
1046 "'9010788312004066376x-6609234393368420856x');"));
1047 ASSERT_TRUE(connection
->CommitTransaction());
1050 void MigrationTest::SetUpVersion73Database(sql::Connection
* connection
) {
1051 ASSERT_TRUE(connection
->is_open());
1052 ASSERT_TRUE(connection
->BeginTransaction());
1053 ASSERT_TRUE(connection
->Execute(
1054 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1055 "INSERT INTO 'share_version' VALUES('nick@chromium.org',73);"
1056 "CREATE TABLE metas(metahandle bigint primary key ON CONFLICT FAIL,"
1057 "base_version bigint default -1,server_version bigint default 0,"
1058 "mtime bigint default 0,server_mtime bigint default 0,ctime bigint "
1059 "default 0,server_ctime bigint default 0,server_position_in_parent "
1060 "bigint default 0,local_external_id bigint default 0,id varchar(255) "
1061 "default 'r',parent_id varchar(255) default 'r',server_parent_id "
1062 "varchar(255) default 'r',prev_id varchar(255) default 'r',next_id "
1063 "varchar(255) default 'r',is_unsynced bit default 0,"
1064 "is_unapplied_update bit default 0,is_del bit default 0,is_dir bit "
1065 "default 0,server_is_dir bit default 0,server_is_del bit default 0,"
1066 "non_unique_name varchar,server_non_unique_name varchar(255),"
1067 "unique_server_tag varchar,unique_client_tag varchar,specifics blob,"
1068 "server_specifics blob);"
1069 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1070 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,"
1071 "NULL,NULL,X'',X'');"
1072 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1074 "'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,"
1075 "'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F"
1076 "7777772E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A1768"
1077 "7474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474144"
1079 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1081 "'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,"
1082 "'Welcome to Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A31"
1083 "687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F"
1084 "656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7777"
1085 "772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D"
1086 "652E68746D6C1200');"
1087 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1089 "'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google',"
1090 "'Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652"
1091 "E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E6"
1092 "76F6F676C652E636F6D2F12084147464447415347');"
1093 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1095 "'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet',"
1096 "'The Internet',NULL,NULL,X'C2881000',X'C2881000');"
1097 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1099 "'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome'"
1100 ",'google_chrome',NULL,NULL,NULL);"
1101 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1103 "'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks',"
1104 "'Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1105 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1107 "'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar',"
1108 "'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1109 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1111 "'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,"
1112 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,"
1113 "X'C2881000',X'C2881000');"
1114 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1116 "'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,"
1117 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,"
1118 "NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1"
1119 "206414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
1120 "D2E6F72672F6F7468657212084146414756415346');"
1121 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1123 "'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,"
1124 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',"
1126 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1128 "'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,"
1129 "'ICANN | Internet Corporation for Assigned Names and Numbers',"
1130 "'ICANN | Internet Corporation for Assigned Names and Numbers',NULL,"
1131 "NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
1132 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2"
1133 "E636F6D2F120744414146415346');"
1134 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1136 "'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,"
1137 "'The WebKit Open Source Project','The WebKit Open Source Project',"
1138 "NULL,NULL,""X'C288101A0A12687474703A2F2F7765626B69742E6F72672F120450"
1139 "4E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E"
1141 "CREATE TABLE models (model_id BLOB primary key, "
1142 "last_download_timestamp INT, initial_sync_ended BOOLEAN default 0);"
1143 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
1144 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, "
1145 "store_birthday TEXT, db_create_version TEXT, db_create_time INT, "
1146 "next_id INT default -2, cache_guid TEXT, "
1147 "notification_state BLOB);"
1148 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1149 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,"
1150 "'9010788312004066376x-6609234393368420856x',X'C2881000');"));
1151 ASSERT_TRUE(connection
->CommitTransaction());
1154 void MigrationTest::SetUpVersion74Database(sql::Connection
* connection
) {
1155 ASSERT_TRUE(connection
->is_open());
1156 ASSERT_TRUE(connection
->BeginTransaction());
1157 ASSERT_TRUE(connection
->Execute(
1158 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1159 "INSERT INTO 'share_version' VALUES('nick@chromium.org',74);"
1160 "CREATE TABLE models (model_id BLOB primary key, last_download_timestamp"
1161 " INT, initial_sync_ended BOOLEAN default 0);"
1162 "INSERT INTO 'models' VALUES(X'C2881000',694,1);"
1163 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthd"
1164 "ay TEXT, db_create_version TEXT, db_create_time INT, next_id INT de"
1165 "fault -2, cache_guid TEXT , notification_state BLOB, autofill_migra"
1166 "tion_state INT default 0, bookmarks_added_during_autofill_migration"
1167 " INT default 0, autofill_migration_time INT default 0, autofill_ent"
1168 "ries_added_during_migration INT default 0, autofill_profiles_added_"
1169 "during_migration INT default 0);"
1170 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'"
1171 ",'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542"
1172 ",'9010788312004066376x-6609234393368420856x',NULL,0,0,0,0,0);"
1173 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,bas"
1174 "e_version bigint default -1,server_version bigint default 0,mtime b"
1175 "igint default 0,server_mtime bigint default 0,ctime bigint default "
1176 "0,server_ctime bigint default 0,server_position_in_parent bigint de"
1177 "fault 0,local_external_id bigint default 0,id varchar(255) default "
1178 "'r',parent_id varchar(255) default 'r',server_parent_id varchar(255"
1179 ") default 'r',prev_id varchar(255) default 'r',next_id varchar(255)"
1180 " default 'r',is_unsynced bit default 0,is_unapplied_update bit defa"
1181 "ult 0,is_del bit default 0,is_dir bit default 0,server_is_dir bit d"
1182 "efault 0,server_is_del bit default 0,non_unique_name varchar,server"
1183 "_non_unique_name varchar(255),unique_server_tag varchar,unique_clie"
1184 "nt_tag varchar,specifics blob,server_specifics blob);"
1185 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1186 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'"
1188 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1189 ",-2097152,4,'s_ID_2','s_ID"
1190 "_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Item','Deleted "
1191 "Item',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E6"
1192 "36F6D2F12084141534741534741',X'C28810260A17687474703A2F2F7777772E67"
1193 "6F6F676C652E636F6D2F32120B4153414447414447414447');"
1194 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1195 ",-3145728,3,'s_ID_4','s_ID"
1196 "_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to Chromium','W"
1197 "elcome to Chromium',NULL,NULL,X'C28810350A31687474703A2F2F7777772E6"
1198 "76F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E"
1199 "68746D6C1200',X'C28810350A31687474703A2F2F7777772E676F6F676C652E636"
1200 "F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E68746D6C1200');"
1201 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1202 ",1048576,7,'s_ID_5','s_ID_"
1203 "9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Google',NULL,NU"
1204 "LL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F120841"
1205 "47415347415347',X'C28810220A16687474703A2F2F7777772E676F6F676C652E6"
1206 "36F6D2F12084147464447415347');"
1207 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1208 ",-4194304,6,'s_ID_6','s_ID"
1209 "_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The Internet',NULL"
1210 ",NULL,X'C2881000',X'C2881000');"
1211 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1212 ",1048576,0,'s_ID_7','r','r"
1213 "','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google_chrom"
1214 "e',NULL,NULL,NULL);"
1215 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1216 ",1048576,0,'s_ID_8','s_ID_"
1217 "7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks','google_chr"
1218 "ome_bookmarks',NULL,X'C2881000',X'C2881000');"
1219 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1220 ",1048576,1,'s_ID_9','s_ID_"
1221 "8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar'"
1222 ",'bookmark_bar',NULL,X'C2881000',X'C2881000');"
1223 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1224 ",2097152,2,'s_ID_10','s_I"
1225 "D_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks','Other Boo"
1226 "kmarks','other_bookmarks',NULL,X'C2881000',X'C2881000');"
1227 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1228 ",-1048576,8,'s_ID_11','s_"
1229 "ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chromium Projec"
1230 "ts)','Home (The Chromium Projects)',NULL,NULL,X'C28810220A186874747"
1231 "03A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741',X'C28810"
1232 "290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74686572120"
1233 "84146414756415346');"
1234 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1235 ",0,9,'s_ID_12','s_ID_6','"
1236 "s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bo"
1237 "okmarks',NULL,NULL,X'C2881000',X'C2881000');"
1238 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1239 ",-917504,10,'s_ID_13','s_"
1240 "ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN | Internet Co"
1241 "rporation for Assigned Names and Numbers','ICANN | Internet Corpora"
1242 "tion for Assigned Names and Numbers',NULL,NULL,X'C28810240A15687474"
1243 "703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',X'C"
1244 "28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F12074441414641"
1246 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1247 ",1048576,11,'s_ID_14','s_"
1248 "ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Open Source Pr"
1249 "oject','The WebKit Open Source Project',NULL,NULL,X'C288101A0A12687"
1250 "474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101C0A13687474"
1251 "703A2F2F7765626B69742E6F72672F781205504E473259');"
1253 ASSERT_TRUE(connection
->CommitTransaction());
1256 void MigrationTest::SetUpVersion75Database(sql::Connection
* connection
) {
1257 ASSERT_TRUE(connection
->is_open());
1258 ASSERT_TRUE(connection
->BeginTransaction());
1259 ASSERT_TRUE(connection
->Execute(
1260 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1261 "INSERT INTO 'share_version' VALUES('nick@chromium.org',75);"
1262 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthd"
1263 "ay TEXT, db_create_version TEXT, db_create_time INT, next_id INT de"
1264 "fault -2, cache_guid TEXT , notification_state BLOB, autofill_migra"
1265 "tion_state INT default 0,bookmarks_added_during_autofill_migration "
1266 "INT default 0, autofill_migration_time INT default 0, autofill_entr"
1267 "ies_added_during_migration INT default 0, autofill_profiles_added_d"
1268 "uring_migration INT default 0);"
1269 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org"
1270 "','c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-655"
1271 "42,'9010788312004066376x-6609234393368420856x',NULL,0,0,0,0,0);"
1272 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, "
1273 "initial_sync_ended BOOLEAN default 0);"
1274 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1275 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,ba"
1276 "se_version bigint default -1,server_version bigint default 0,mtime"
1277 " bigint default 0,server_mtime bigint default 0,ctime bigint defau"
1278 "lt 0,server_ctime bigint default 0,server_position_in_parent bigin"
1279 "t default 0,local_external_id bigint default 0,id varchar(255) def"
1280 "ault 'r',parent_id varchar(255) default 'r',server_parent_id varch"
1281 "ar(255) default 'r',prev_id varchar(255) default 'r',next_id varch"
1282 "ar(255) default 'r',is_unsynced bit default 0,is_unapplied_update "
1283 "bit default 0,is_del bit default 0,is_dir bit default 0,server_is_"
1284 "dir bit default 0,server_is_del bit default 0,non_unique_name varc"
1285 "har,server_non_unique_name varchar(255),unique_server_tag varchar,"
1286 "unique_client_tag varchar,specifics blob,server_specifics blob);"
1287 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1288 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NUL"
1290 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1291 ",-2097152,4,'s_ID_"
1292 "2','s_ID_9','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Ite"
1293 "m','Deleted Item',NULL,NULL,X'C28810220A16687474703A2F2F7777772"
1294 "E676F6F676C652E636F6D2F12084141534741534741',X'C28810260A176874"
1295 "74703A2F2F7777772E676F6F676C652E636F6D2F32120B41534144474144474"
1297 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1298 ",-3145728,3,'s_ID_"
1299 "4','s_ID_9','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to "
1300 "Chromium','Welcome to Chromium',NULL,NULL,X'C28810350A316874747"
1301 "03A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F65"
1302 "6E2F77656C636F6D652E68746D6C1200',X'C28810350A31687474703A2F2F7"
1303 "777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656E2F7765"
1304 "6C636F6D652E68746D6C1200');"
1305 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1306 ",1048576,7,'s_ID_5"
1307 "','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Goo"
1308 "gle',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C65"
1309 "2E636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F777"
1310 "7772E676F6F676C652E636F6D2F12084147464447415347');"
1311 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1312 ",-4194304,6,'s_ID_"
1313 "6','s_ID_9','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The In"
1314 "ternet',NULL,NULL,X'C2881000',X'C2881000');"
1315 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1316 ",1048576,0,'s_ID_7"
1317 "','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','"
1318 "google_chrome',NULL,NULL,NULL);"
1319 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1320 ",1048576,0,'s_ID_8"
1321 "','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks'"
1322 ",'google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1323 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1324 ",1048576,1,'s_ID_9"
1325 "','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','B"
1326 "ookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1327 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1329 "10','s_ID_8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks"
1330 "','Other Bookmarks','other_bookmarks',NULL,X'C2881000',X'C28810"
1332 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1334 "_11','s_ID_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chr"
1335 "omium Projects)','Home (The Chromium Projects)',NULL,NULL,X'C28"
1336 "810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F120641"
1337 "4741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756"
1338 "D2E6F72672F6F7468657212084146414756415346');"
1339 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1341 "_ID_6','s_ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmark"
1342 "s','Extra Bookmarks',NULL,NULL,X'C2881000',X'C2881000');"
1343 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1345 "_13','s_ID_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN |"
1346 " Internet Corporation for Assigned Names and Numbers','ICANN | "
1347 "Internet Corporation for Assigned Names and Numbers',NULL,NULL,"
1348 "X'C28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504"
1349 "E474158463041414646',X'C28810200A15687474703A2F2F7777772E696361"
1350 "6E6E2E636F6D2F120744414146415346');"
1351 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1353 "_14','s_ID_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Op"
1354 "en Source Project','The WebKit Open Source Project',NULL,NULL,X"
1355 "'C288101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',"
1356 "X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E473"
1359 ASSERT_TRUE(connection
->CommitTransaction());
1362 void MigrationTest::SetUpVersion76Database(sql::Connection
* connection
) {
1363 ASSERT_TRUE(connection
->is_open());
1364 ASSERT_TRUE(connection
->BeginTransaction());
1365 ASSERT_TRUE(connection
->Execute(
1366 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1367 "INSERT INTO 'share_version' VALUES('nick@chromium.org',76);"
1368 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1369 "itial_sync_ended BOOLEAN default 0);"
1370 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1371 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1372 "_version bigint default -1,server_version bigint default 0,mtime big"
1373 "int default 0,server_mtime bigint default 0,ctime bigint default 0,s"
1374 "erver_ctime bigint default 0,server_position_in_parent bigint defaul"
1375 "t 0,local_external_id bigint default 0,id varchar(255) default 'r',p"
1376 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1377 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1378 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1379 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1380 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1381 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1382 "har,specifics blob,server_specifics blob);"
1383 "INSERT INTO 'metas' VALUES(1,-1,0," LEGACY_PROTO_TIME_VALS(1)
1384 ",0,0,'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'')"
1386 "INSERT INTO 'metas' VALUES(2,669,669," LEGACY_PROTO_TIME_VALS(2)
1387 ",-2097152,4,'s_ID_2','s_ID_9"
1388 "','s_ID_9','s_ID_2','s_ID_2',0,0,1,0,0,1,'Deleted Item','Deleted Ite"
1389 "m',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6"
1390 "D2F12084141534741534741',X'C28810260A17687474703A2F2F7777772E676F6F6"
1391 "76C652E636F6D2F32120B4153414447414447414447');"
1392 "INSERT INTO 'metas' VALUES(4,681,681," LEGACY_PROTO_TIME_VALS(4)
1393 ",-3145728,3,'s_ID_4','s_ID_9"
1394 "','s_ID_9','s_ID_4','s_ID_4',0,0,1,0,0,1,'Welcome to Chromium','Welc"
1395 "ome to Chromium',NULL,NULL,X'C28810350A31687474703A2F2F7777772E676F6"
1396 "F676C652E636F6D2F6368726F6D652F696E746C2F656E2F77656C636F6D652E68746"
1397 "D6C1200',X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6"
1398 "368726F6D652F696E746C2F656E2F77656C636F6D652E68746D6C1200');"
1399 "INSERT INTO 'metas' VALUES(5,677,677," LEGACY_PROTO_TIME_VALS(5)
1400 ",1048576,7,'s_ID_5','s_ID_9'"
1401 ",'s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','Google',NULL,NULL,"
1402 "X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D2F1208414741"
1403 "5347415347',X'C28810220A16687474703A2F2F7777772E676F6F676C652E636F6D"
1404 "2F12084147464447415347');"
1405 "INSERT INTO 'metas' VALUES(6,694,694," LEGACY_PROTO_TIME_VALS(6)
1406 ",-4194304,6,'s_ID_6','s_ID_9"
1407 "','s_ID_9','r','r',0,0,0,1,1,0,'The Internet','The Internet',NULL,NU"
1408 "LL,X'C2881000',X'C2881000');"
1409 "INSERT INTO 'metas' VALUES(7,663,663," LEGACY_PROTO_TIME_VALS(7)
1410 ",1048576,0,'s_ID_7','r','r',"
1411 "'r','r',0,0,0,1,1,0,'Google Chrome','Google Chrome','google_chrome',"
1413 "INSERT INTO 'metas' VALUES(8,664,664," LEGACY_PROTO_TIME_VALS(8)
1414 ",1048576,0,'s_ID_8','s_ID_7'"
1415 ",'s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmarks','google_chrome"
1416 "_bookmarks',NULL,X'C2881000',X'C2881000');"
1417 "INSERT INTO 'metas' VALUES(9,665,665," LEGACY_PROTO_TIME_VALS(9)
1418 ",1048576,1,'s_ID_9','s_ID_8'"
1419 ",'s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar','Bookmark Bar','b"
1420 "ookmark_bar',NULL,X'C2881000',X'C2881000');"
1421 "INSERT INTO 'metas' VALUES(10,666,666," LEGACY_PROTO_TIME_VALS(10)
1422 ",2097152,2,'s_ID_10','s_ID_"
1423 "8','s_ID_8','s_ID_9','r',0,0,0,1,1,0,'Other Bookmarks','Other Bookma"
1424 "rks','other_bookmarks',NULL,X'C2881000',X'C2881000');"
1425 "INSERT INTO 'metas' VALUES(11,683,683," LEGACY_PROTO_TIME_VALS(11)
1426 ",-1048576,8,'s_ID_11','s_ID"
1427 "_6','s_ID_6','r','s_ID_13',0,0,0,0,0,0,'Home (The Chromium Projects)"
1428 "','Home (The Chromium Projects)',NULL,NULL,X'C28810220A18687474703A2"
1429 "F2F6465762E6368726F6D69756D2E6F72672F1206414741545741',X'C28810290A1"
1430 "D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F74686572120841464"
1432 "INSERT INTO 'metas' VALUES(12,685,685," LEGACY_PROTO_TIME_VALS(12)
1433 ",0,9,'s_ID_12','s_ID_6','s_"
1434 "ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookm"
1435 "arks',NULL,NULL,X'C2881000',X'C2881000');"
1436 "INSERT INTO 'metas' VALUES(13,687,687," LEGACY_PROTO_TIME_VALS(13)
1437 ",-917504,10,'s_ID_13','s_ID"
1438 "_6','s_ID_6','s_ID_11','s_ID_12',0,0,0,0,0,0,'ICANN | Internet Corpo"
1439 "ration for Assigned Names and Numbers','ICANN | Internet Corporation"
1440 " for Assigned Names and Numbers',NULL,NULL,X'C28810240A15687474703A2"
1441 "F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',X'C288102"
1442 "00A15687474703A2F2F7777772E6963616E6E2E636F6D2F120744414146415346');"
1443 "INSERT INTO 'metas' VALUES(14,692,692," LEGACY_PROTO_TIME_VALS(14)
1444 ",1048576,11,'s_ID_14','s_ID"
1445 "_6','s_ID_6','s_ID_12','r',0,0,0,0,0,0,'The WebKit Open Source Proje"
1446 "ct','The WebKit Open Source Project',NULL,NULL,X'C288101A0A126874747"
1447 "03A2F2F7765626B69742E6F72672F1204504E4758',X'C288101C0A13687474703A2"
1448 "F2F7765626B69742E6F72672F781205504E473259');"
1449 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1450 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1451 "ult -2, cache_guid TEXT , notification_state BLOB);"
1452 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1453 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"
1454 "9010788312004066376x-6609234393368420856x',NULL);"
1456 ASSERT_TRUE(connection
->CommitTransaction());
1459 void MigrationTest::SetUpVersion77Database(sql::Connection
* connection
) {
1460 ASSERT_TRUE(connection
->is_open());
1461 ASSERT_TRUE(connection
->BeginTransaction());
1462 ASSERT_TRUE(connection
->Execute(
1463 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1464 "INSERT INTO 'share_version' VALUES('nick@chromium.org',77);"
1465 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1466 "itial_sync_ended BOOLEAN default 0);"
1467 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1468 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1469 "_version bigint default -1,server_version bigint default 0,server_po"
1470 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1471 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1472 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1473 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1474 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1475 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1476 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1477 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1478 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1479 "har,specifics blob,server_specifics blob);"
1480 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1)
1481 ",'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'');"
1482 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1483 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1484 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1485 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1486 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1487 "14447414447414447');"
1488 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1489 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1490 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1491 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1492 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1493 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1494 "E2F77656C636F6D652E68746D6C1200');"
1495 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7," META_PROTO_TIMES_VALS(5)
1496 ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','"
1497 "Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E"
1498 "636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E67"
1499 "6F6F676C652E636F6D2F12084147464447415347');"
1500 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1501 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1502 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1504 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0," META_PROTO_TIMES_VALS(7)
1505 ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Goo"
1506 "gle Chrome','google_chrome',NULL,NULL,NULL);"
1507 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0," META_PROTO_TIMES_VALS(8)
1508 ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmar"
1509 "ks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1510 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1," META_PROTO_TIMES_VALS(9)
1511 ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar'"
1512 ",'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1513 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1514 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1515 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1516 "LL,X'C2881000',X'C2881000');"
1517 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1518 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1519 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1520 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1521 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1522 "8726F6D69756D2E6F72672F6F7468657212084146414756415346');"
1523 "INSERT INTO 'metas' VALUES(12,685,685,0,9," META_PROTO_TIMES_VALS(12)
1524 ",'s_ID_12','s_ID_6','s_"
1525 "ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookm"
1526 "arks',NULL,NULL,X'C2881000',X'C2881000');"
1527 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1528 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1529 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1530 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1531 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1532 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1533 "E6963616E6E2E636F6D2F120744414146415346');"
1534 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1535 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1536 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1537 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1538 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1539 "81205504E473259');"
1540 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1541 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1542 "ult -2, cache_guid TEXT , notification_state BLOB);"
1543 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1544 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"
1545 "9010788312004066376x-6609234393368420856x',NULL);"
1547 ASSERT_TRUE(connection
->CommitTransaction());
1550 void MigrationTest::SetUpVersion78Database(sql::Connection
* connection
) {
1551 ASSERT_TRUE(connection
->is_open());
1552 ASSERT_TRUE(connection
->BeginTransaction());
1553 ASSERT_TRUE(connection
->Execute(
1554 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1555 "INSERT INTO 'share_version' VALUES('nick@chromium.org',78);"
1556 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1557 "itial_sync_ended BOOLEAN default 0);"
1558 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1559 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1560 "_version bigint default -1,server_version bigint default 0,server_po"
1561 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1562 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1563 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1564 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1565 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1566 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1567 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1568 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1569 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1570 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1572 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1573 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL);"
1574 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1575 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1576 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1577 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1578 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1579 "14447414447414447',NULL);"
1580 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1581 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1582 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1583 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1584 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1585 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1586 "E2F77656C636F6D652E68746D6C1200',NULL);"
1587 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7,"
1588 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1589 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1590 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1591 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1593 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1594 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1595 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1597 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0,"
1598 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1599 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL);"
1600 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0,"
1601 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1602 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1603 "00',X'C2881000',NULL);"
1604 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1,"
1605 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1606 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1607 "000',X'C2881000',NULL);"
1608 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1609 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1610 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1611 "LL,X'C2881000',X'C2881000',NULL);"
1612 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1613 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1614 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1615 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1616 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1617 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL);"
1618 "INSERT INTO 'metas' VALUES(12,685,685,0,9,"
1619 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1620 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1621 "2881000',X'C2881000',NULL);"
1622 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1623 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1624 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1625 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1626 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1627 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1628 "E6963616E6E2E636F6D2F120744414146415346',NULL);"
1629 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1630 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1631 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1632 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1633 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1634 "81205504E473259',NULL);"
1635 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1636 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1637 "ult -2, cache_guid TEXT , notification_state BLOB);"
1638 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1639 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"
1640 "9010788312004066376x-6609234393368420856x',NULL);"
1642 ASSERT_TRUE(connection
->CommitTransaction());
1645 void MigrationTest::SetUpVersion79Database(sql::Connection
* connection
) {
1646 ASSERT_TRUE(connection
->is_open());
1647 ASSERT_TRUE(connection
->BeginTransaction());
1648 ASSERT_TRUE(connection
->Execute(
1649 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1650 "INSERT INTO 'share_version' VALUES('nick@chromium.org',79);"
1651 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1652 "itial_sync_ended BOOLEAN default 0);"
1653 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1654 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1655 "_version bigint default -1,server_version bigint default 0,server_po"
1656 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1657 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1658 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1659 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1660 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1661 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1662 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1663 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1664 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1665 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1667 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1668 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL);"
1669 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1670 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1671 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1672 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1673 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1674 "14447414447414447',NULL);"
1675 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1676 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1677 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1678 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1679 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1680 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1681 "E2F77656C636F6D652E68746D6C1200',NULL);"
1682 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7,"
1683 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1684 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1685 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1686 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1688 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1689 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1690 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1692 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0,"
1693 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1694 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL);"
1695 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0,"
1696 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1697 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1698 "00',X'C2881000',NULL);"
1699 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1,"
1700 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1701 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1702 "000',X'C2881000',NULL);"
1703 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1704 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1705 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1706 "LL,X'C2881000',X'C2881000',NULL);"
1707 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1708 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1709 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1710 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1711 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1712 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL);"
1713 "INSERT INTO 'metas' VALUES(12,685,685,0,9,"
1714 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1715 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1716 "2881000',X'C2881000',NULL);"
1717 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1718 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1719 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1720 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1721 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1722 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1723 "E6963616E6E2E636F6D2F120744414146415346',NULL);"
1724 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1725 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1726 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1727 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1728 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1729 "81205504E473259',NULL);"
1730 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1731 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1732 "ult -2, cache_guid TEXT , notification_state BLOB);"
1733 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1734 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
1735 "-131078,'9010788312004066376x-6609234393368420856x',NULL);"
1737 ASSERT_TRUE(connection
->CommitTransaction());
1740 void MigrationTest::SetUpVersion80Database(sql::Connection
* connection
) {
1741 ASSERT_TRUE(connection
->is_open());
1742 ASSERT_TRUE(connection
->BeginTransaction());
1743 ASSERT_TRUE(connection
->Execute(
1744 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1745 "INSERT INTO 'share_version' VALUES('nick@chromium.org',80);"
1746 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1747 "itial_sync_ended BOOLEAN default 0);"
1748 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1749 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1750 "_version bigint default -1,server_version bigint default 0,server_po"
1751 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1752 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1753 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1754 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1755 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1756 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1757 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1758 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1759 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1760 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1762 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1763 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL);"
1764 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1765 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1766 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1767 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1768 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1769 "14447414447414447',NULL);"
1770 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1771 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1772 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1773 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1774 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1775 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1776 "E2F77656C636F6D652E68746D6C1200',NULL);"
1777 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7,"
1778 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1779 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1780 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1781 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1783 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1784 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1785 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1787 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0,"
1788 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1789 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL);"
1790 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0,"
1791 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1792 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1793 "00',X'C2881000',NULL);"
1794 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1,"
1795 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1796 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1797 "000',X'C2881000',NULL);"
1798 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1799 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1800 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1801 "LL,X'C2881000',X'C2881000',NULL);"
1802 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1803 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1804 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1805 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1806 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1807 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL);"
1808 "INSERT INTO 'metas' VALUES(12,685,685,0,9,"
1809 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1810 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1811 "2881000',X'C2881000',NULL);"
1812 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1813 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1814 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1815 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1816 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1817 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1818 "E6963616E6E2E636F6D2F120744414146415346',NULL);"
1819 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1820 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1821 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1822 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1823 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1824 "81205504E473259',NULL);"
1825 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1826 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1827 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
1829 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1830 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
1831 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"
1833 ASSERT_TRUE(connection
->CommitTransaction());
1837 // Helper definitions to create the version 81 DB tables.
1840 const int V80_ROW_COUNT
= 13;
1841 const int64 V80_POSITIONS
[V80_ROW_COUNT
] = {
1857 std::string
V81_Ordinal(int n
) {
1858 return Int64ToNodeOrdinal(V80_POSITIONS
[n
]).ToInternalValue();
1863 // Unlike the earlier versions, the rows for version 81 are generated
1864 // programmatically to accurately handle unprintable characters for the
1865 // server_ordinal_in_parent field.
1866 void MigrationTest::SetUpVersion81Database(sql::Connection
* connection
) {
1867 ASSERT_TRUE(connection
->is_open());
1868 ASSERT_TRUE(connection
->BeginTransaction());
1869 ASSERT_TRUE(connection
->Execute(
1870 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1871 "INSERT INTO 'share_version' VALUES('nick@chromium.org',81);"
1872 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1873 "itial_sync_ended BOOLEAN default 0);"
1874 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1875 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1876 "_version bigint default -1,server_version bigint default 0, "
1877 "local_external_id bigint default 0"
1878 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1879 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1880 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1881 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1882 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1883 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1884 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1885 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1886 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1887 ", server_ordinal_in_parent blob);"
1888 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1889 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1890 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
1892 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1893 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
1894 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
1896 const char* insert_stmts
[V80_ROW_COUNT
] = {
1897 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
1898 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?);",
1899 "INSERT INTO 'metas' VALUES(2,669,669,4,"
1900 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1901 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1902 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1903 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1904 "14447414447414447',NULL,?);",
1905 "INSERT INTO 'metas' VALUES(4,681,681,3,"
1906 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1907 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1908 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1909 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1910 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1911 "E2F77656C636F6D652E68746D6C1200',NULL,?);",
1912 "INSERT INTO 'metas' VALUES(5,677,677,7,"
1913 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
1914 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
1915 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
1916 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
1918 "INSERT INTO 'metas' VALUES(6,694,694,6,"
1919 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1920 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1922 "INSERT INTO 'metas' VALUES(7,663,663,0,"
1923 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
1924 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?);",
1925 "INSERT INTO 'metas' VALUES(8,664,664,0,"
1926 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
1927 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
1928 "00',X'C2881000',NULL,?);",
1929 "INSERT INTO 'metas' VALUES(9,665,665,1,"
1930 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
1931 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
1932 "000',X'C2881000',NULL,?);",
1933 "INSERT INTO 'metas' VALUES(10,666,666,2,"
1934 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1935 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1936 "LL,X'C2881000',X'C2881000',NULL,?);",
1937 "INSERT INTO 'metas' VALUES(11,683,683,8,"
1938 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1939 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1940 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1941 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1942 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?);",
1943 "INSERT INTO 'metas' VALUES(12,685,685,9,"
1944 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
1945 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
1946 "2881000',X'C2881000',NULL,?);",
1947 "INSERT INTO 'metas' VALUES(13,687,687,10,"
1948 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1949 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1950 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1951 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1952 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1953 "E6963616E6E2E636F6D2F120744414146415346',NULL,?);",
1954 "INSERT INTO 'metas' VALUES(14,692,692,11,"
1955 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1956 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1957 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1958 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1959 "81205504E473259',NULL,?);" };
1961 for (int i
= 0; i
< V80_ROW_COUNT
; i
++) {
1962 sql::Statement
s(connection
->GetUniqueStatement(insert_stmts
[i
]));
1963 std::string ord
= V81_Ordinal(i
);
1964 s
.BindBlob(0, ord
.data(), ord
.length());
1965 ASSERT_TRUE(s
.Run());
1968 ASSERT_TRUE(connection
->CommitTransaction());
1971 void MigrationTest::SetUpVersion82Database(sql::Connection
* connection
) {
1972 ASSERT_TRUE(connection
->is_open());
1973 ASSERT_TRUE(connection
->BeginTransaction());
1974 ASSERT_TRUE(connection
->Execute(
1975 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1976 "INSERT INTO 'share_version' VALUES('nick@chromium.org',82);"
1977 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1978 "itial_sync_ended BOOLEAN default 0, transaction_version BIGINT "
1980 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1, 1);"
1981 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1982 "_version bigint default -1,server_version bigint default 0, "
1983 "local_external_id bigint default 0"
1984 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1985 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1986 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1987 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1988 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1989 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1990 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1991 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1992 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
1993 ", server_ordinal_in_parent blob);"
1994 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1995 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1996 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
1998 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1999 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2000 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2002 const char* insert_stmts
[V80_ROW_COUNT
] = {
2003 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2004 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?);",
2005 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2006 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2007 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2008 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2009 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2010 "14447414447414447',NULL,?);",
2011 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2012 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2013 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2014 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2015 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2016 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2017 "E2F77656C636F6D652E68746D6C1200',NULL,?);",
2018 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2019 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2020 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2021 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2022 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2024 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2025 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2026 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2028 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2029 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2030 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?);",
2031 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2032 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2033 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2034 "00',X'C2881000',NULL,?);",
2035 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2036 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2037 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2038 "000',X'C2881000',NULL,?);",
2039 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2040 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2041 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2042 "LL,X'C2881000',X'C2881000',NULL,?);",
2043 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2044 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2045 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2046 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2047 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2048 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?);",
2049 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2050 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2051 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2052 "2881000',X'C2881000',NULL,?);",
2053 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2054 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2055 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2056 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2057 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2058 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2059 "E6963616E6E2E636F6D2F120744414146415346',NULL,?);",
2060 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2061 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2062 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2063 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2064 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2065 "81205504E473259',NULL,?);" };
2067 for (int i
= 0; i
< V80_ROW_COUNT
; i
++) {
2068 sql::Statement
s(connection
->GetUniqueStatement(insert_stmts
[i
]));
2069 std::string ord
= V81_Ordinal(i
);
2070 s
.BindBlob(0, ord
.data(), ord
.length());
2071 ASSERT_TRUE(s
.Run());
2074 ASSERT_TRUE(connection
->CommitTransaction());
2077 void MigrationTest::SetUpVersion83Database(sql::Connection
* connection
) {
2078 ASSERT_TRUE(connection
->is_open());
2079 ASSERT_TRUE(connection
->BeginTransaction());
2080 ASSERT_TRUE(connection
->Execute(
2081 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2082 "INSERT INTO 'share_version' VALUES('nick@chromium.org',83);"
2083 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
2084 "itial_sync_ended BOOLEAN default 0, transaction_version BIGINT "
2086 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1, 1);"
2087 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2088 "_version bigint default -1,server_version bigint default 0, "
2089 "local_external_id bigint default 0"
2090 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2091 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2092 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2093 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2094 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2095 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2096 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2097 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2098 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2099 ", server_ordinal_in_parent blob, transaction_version bigint default "
2101 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2102 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
2103 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2105 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2106 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2107 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2109 const char* insert_stmts
[V80_ROW_COUNT
] = {
2110 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2111 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?,0);",
2112 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2113 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2114 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2115 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2116 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2117 "14447414447414447',NULL,?,0);",
2118 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2119 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2120 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2121 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2122 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2123 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2124 "E2F77656C636F6D652E68746D6C1200',NULL,?,0);",
2125 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2126 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2127 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2128 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2129 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2131 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2132 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2133 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2135 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2136 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2137 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?,0);"
2139 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2140 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2141 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2142 "00',X'C2881000',NULL,?,0);",
2143 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2144 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2145 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2146 "000',X'C2881000',NULL,?,0);",
2147 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2148 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2149 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2150 "LL,X'C2881000',X'C2881000',NULL,?,0);",
2151 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2152 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2153 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2154 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2155 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2156 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?,0);",
2157 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2158 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2159 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2160 "2881000',X'C2881000',NULL,?,0);",
2161 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2162 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2163 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2164 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2165 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2166 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2167 "E6963616E6E2E636F6D2F120744414146415346',NULL,?,0);",
2168 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2169 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2170 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2171 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2172 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2173 "81205504E473259',NULL,?,0);" };
2175 for (int i
= 0; i
< V80_ROW_COUNT
; i
++) {
2176 sql::Statement
s(connection
->GetUniqueStatement(insert_stmts
[i
]));
2177 std::string ord
= V81_Ordinal(i
);
2178 s
.BindBlob(0, ord
.data(), ord
.length());
2179 ASSERT_TRUE(s
.Run());
2182 ASSERT_TRUE(connection
->CommitTransaction());
2185 void MigrationTest::SetUpVersion84Database(sql::Connection
* connection
) {
2186 ASSERT_TRUE(connection
->is_open());
2187 ASSERT_TRUE(connection
->BeginTransaction());
2188 ASSERT_TRUE(connection
->Execute(
2189 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2190 "INSERT INTO 'share_version' VALUES('nick@chromium.org',84);"
2191 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
2192 "itial_sync_ended BOOLEAN default 0, transaction_version BIGINT "
2194 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1, 1);"
2195 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2196 "_version bigint default -1,server_version bigint default 0, "
2197 "local_external_id bigint default 0"
2198 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2199 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2200 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2201 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2202 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2203 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2204 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2205 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2206 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2207 ", server_ordinal_in_parent blob, transaction_version bigint default "
2209 "CREATE TABLE 'deleted_metas'"
2210 "(metahandle bigint primary key ON CONFLICT FAIL,base"
2211 "_version bigint default -1,server_version bigint default 0, "
2212 "local_external_id bigint default 0"
2213 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2214 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2215 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2216 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2217 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2218 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2219 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2220 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2221 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2222 ", server_ordinal_in_parent blob, transaction_version bigint default "
2224 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2225 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
2226 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2228 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2229 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2230 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2232 const char* insert_stmts
[V80_ROW_COUNT
] = {
2233 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2234 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?,0);",
2235 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2236 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2237 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2238 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2239 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2240 "14447414447414447',NULL,?,0);",
2241 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2242 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2243 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2244 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2245 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2246 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2247 "E2F77656C636F6D652E68746D6C1200',NULL,?,0);",
2248 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2249 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2250 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2251 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2252 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2254 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2255 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2256 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2258 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2259 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2260 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?,0);"
2262 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2263 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2264 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2265 "00',X'C2881000',NULL,?,0);",
2266 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2267 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2268 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2269 "000',X'C2881000',NULL,?,0);",
2270 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2271 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2272 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2273 "LL,X'C2881000',X'C2881000',NULL,?,0);",
2274 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2275 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2276 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2277 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2278 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2279 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?,0);",
2280 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2281 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2282 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2283 "2881000',X'C2881000',NULL,?,0);",
2284 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2285 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2286 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2287 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2288 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2289 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2290 "E6963616E6E2E636F6D2F120744414146415346',NULL,?,0);",
2291 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2292 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2293 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2294 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2295 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2296 "81205504E473259',NULL,?,0);" };
2298 for (int i
= 0; i
< V80_ROW_COUNT
; i
++) {
2299 sql::Statement
s(connection
->GetUniqueStatement(insert_stmts
[i
]));
2300 std::string ord
= V81_Ordinal(i
);
2301 s
.BindBlob(0, ord
.data(), ord
.length());
2302 ASSERT_TRUE(s
.Run());
2305 ASSERT_TRUE(connection
->CommitTransaction());
2308 void MigrationTest::SetUpVersion85Database(sql::Connection
* connection
) {
2309 ASSERT_TRUE(connection
->is_open());
2310 ASSERT_TRUE(connection
->BeginTransaction());
2311 ASSERT_TRUE(connection
->Execute(
2312 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2313 "INSERT INTO 'share_version' VALUES('nick@chromium.org',85);"
2314 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, "
2315 "transaction_version BIGINT default 0);"
2316 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605', 1);"
2317 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
2318 "_version bigint default -1,server_version bigint default 0, "
2319 "local_external_id bigint default 0"
2320 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2321 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2322 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2323 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2324 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2325 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2326 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2327 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2328 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2329 ", server_ordinal_in_parent blob, transaction_version bigint default "
2331 "CREATE TABLE 'deleted_metas'"
2332 "(metahandle bigint primary key ON CONFLICT FAIL,base"
2333 "_version bigint default -1,server_version bigint default 0, "
2334 "local_external_id bigint default 0"
2335 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
2336 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2337 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
2338 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
2339 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2340 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
2341 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
2342 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
2343 "har,specifics blob,server_specifics blob, base_server_specifics BLOB"
2344 ", server_ordinal_in_parent blob, transaction_version bigint default "
2346 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
2347 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
2348 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips "
2350 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
2351 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,"
2352 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);"));
2354 const char* insert_stmts
[V80_ROW_COUNT
] = {
2355 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','"
2356 "r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'',NULL,?,0);",
2357 "INSERT INTO 'metas' VALUES(2,669,669,4,"
2358 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
2359 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
2360 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
2361 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
2362 "14447414447414447',NULL,?,0);",
2363 "INSERT INTO 'metas' VALUES(4,681,681,3,"
2364 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
2365 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
2366 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
2367 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
2368 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
2369 "E2F77656C636F6D652E68746D6C1200',NULL,?,0);",
2370 "INSERT INTO 'metas' VALUES(5,677,677,7,"
2371 META_PROTO_TIMES_VALS(5) ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_"
2372 "5',0,0,1,0,0,1,'Google','Google',NULL,NULL,X'C28810220A16687474703A2"
2373 "F2F7777772E676F6F676C652E636F6D2F12084147415347415347',X'C28810220A1"
2374 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084147464447415347',N"
2376 "INSERT INTO 'metas' VALUES(6,694,694,6,"
2377 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
2378 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
2380 "INSERT INTO 'metas' VALUES(7,663,663,0,"
2381 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Goog"
2382 "le Chrome','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,?,0);"
2384 "INSERT INTO 'metas' VALUES(8,664,664,0,"
2385 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1"
2386 ",1,0,'Bookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C28810"
2387 "00',X'C2881000',NULL,?,0);",
2388 "INSERT INTO 'metas' VALUES(9,665,665,1,"
2389 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0"
2390 ",0,0,1,1,0,'Bookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881"
2391 "000',X'C2881000',NULL,?,0);",
2392 "INSERT INTO 'metas' VALUES(10,666,666,2,"
2393 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
2394 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
2395 "LL,X'C2881000',X'C2881000',NULL,?,0);",
2396 "INSERT INTO 'metas' VALUES(11,683,683,8,"
2397 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
2398 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
2399 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
2400 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
2401 "8726F6D69756D2E6F72672F6F7468657212084146414756415346',NULL,?,0);",
2402 "INSERT INTO 'metas' VALUES(12,685,685,9,"
2403 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6','s_ID_13','s_"
2404 "ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C"
2405 "2881000',X'C2881000',NULL,?,0);",
2406 "INSERT INTO 'metas' VALUES(13,687,687,10,"
2407 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
2408 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
2409 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
2410 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
2411 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
2412 "E6963616E6E2E636F6D2F120744414146415346',NULL,?,0);",
2413 "INSERT INTO 'metas' VALUES(14,692,692,11,"
2414 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
2415 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
2416 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
2417 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
2418 "81205504E473259',NULL,?,0);" };
2420 for (int i
= 0; i
< V80_ROW_COUNT
; i
++) {
2421 sql::Statement
s(connection
->GetUniqueStatement(insert_stmts
[i
]));
2422 std::string ord
= V81_Ordinal(i
);
2423 s
.BindBlob(0, ord
.data(), ord
.length());
2424 ASSERT_TRUE(s
.Run());
2427 ASSERT_TRUE(connection
->CommitTransaction());
2430 void MigrationTest::SetUpVersion86Database(sql::Connection
* connection
) {
2431 ASSERT_TRUE(connection
->is_open());
2432 ASSERT_TRUE(connection
->BeginTransaction());
2433 ASSERT_TRUE(connection
->Execute(
2434 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
2435 "INSERT INTO 'share_version' VALUES('nick@chromium.org',86);"
2436 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB,"
2437 " transaction_version BIGINT default 0);"
2438 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
2439 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,b"
2440 "ase_version bigint default -1,server_version bigint default 0,local_e"
2441 "xternal_id bigint default 0,transaction_version bigint default 0,mtim"
2442 "e bigint default 0,server_mtime bigint default 0,ctime bigint default"
2443 " 0,server_ctime bigint default 0,id varchar(255) default 'r',parent_i"
2444 "d varchar(255) default 'r',server_parent_id varchar(255) default 'r',"
2445 "is_unsynced bit default 0,is_unapplied_update bit default 0,is_del bi"
2446 "t default 0,is_dir bit default 0,server_is_dir bit default 0,server_i"
2447 "s_del bit default 0,non_unique_name varchar,server_non_unique_name va"
2448 "rchar(255),unique_server_tag varchar,unique_client_tag varchar,specif"
2449 "ics blob,server_specifics blob,base_server_specifics blob,server_uniq"
2450 "ue_position blob,unique_position blob,unique_bookmark_tag blob);"
2451 "INSERT INTO 'metas' VALUES(1,-1,0,0,0,"
2452 META_PROTO_TIMES_VALS(1)
2453 ",'r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,"
2454 "X'',X'',NULL,X'',X'',X'');"
2455 "INSERT INTO 'metas' VALUES(6,694,694,6,0,"
2456 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9',0,0,0,1,1,0,'T"
2457 "he Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000',NULL,X'"
2459 "INSERT INTO 'metas' VALUES(7,663,663,0,0,"
2460 META_PROTO_TIMES_VALS(7) ",'s_ID_7','r','r',0,0,0,1,1,0,'Google Chro"
2461 "me','Google Chrome','google_chrome',NULL,NULL,NULL,NULL,X'',X'',X'');"
2462 "INSERT INTO 'metas' VALUES(8,664,664,0,0,"
2463 META_PROTO_TIMES_VALS(8) ",'s_ID_8','s_ID_7','s_ID_7',0,0,0,1,1,0,'B"
2464 "ookmarks','Bookmarks','google_chrome_bookmarks',NULL,X'C2881000',X'C2"
2465 "881000',NULL,X'',X'',X'');"
2466 "INSERT INTO 'metas' VALUES(9,665,665,1,0,"
2467 META_PROTO_TIMES_VALS(9) ",'s_ID_9','s_ID_8','s_ID_8',0,0,0,1,1,0,'B"
2468 "ookmark Bar','Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C288100"
2469 "0',NULL,X'',X'',X'');"
2470 "INSERT INTO 'metas' VALUES(10,666,666,2,0,"
2471 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8',0,0,0,1,1,0,"
2472 "'Other Bookmarks','Other Bookmarks','other_bookmarks',NULL,X'C2881000"
2473 "',X'C2881000',NULL,X'',X'',X'');"
2474 "INSERT INTO 'metas' VALUES(11,683,683,8,0,"
2475 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6',0,0,0,0,0,0,"
2476 "'Home (The Chromium Projects)','Home (The Chromium Projects)',NULL,NU"
2477 "LL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1206"
2478 "414741545741',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756D2E6"
2479 "F72672F6F7468657212084146414756415346',NULL,X'',X'',X'');"
2480 "INSERT INTO 'metas' VALUES(12,685,685,9,0,"
2481 META_PROTO_TIMES_VALS(12) ",'s_ID_12','s_ID_6','s_ID_6',0,0,0,1,1,0,"
2482 "'Extra Bookmarks','Extra Bookmarks',NULL,NULL,X'C2881000',X'C2881000'"
2483 ",NULL,X'',X'',X'');"
2484 "INSERT INTO 'metas' VALUES(13,687,687,10,0,"
2485 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6',0,0,0,0,0,0"
2486 ",'ICANN | Internet Corporation for Assigned Names and Numbers','ICANN"
2487 " | Internet Corporation for Assigned Names and Numbers',NULL,NULL,X'C"
2488 "28810240A15687474703A2F2F7777772E6963616E6E2E636F6D2F120B504E47415846"
2489 "3041414646',X'C28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F1"
2490 "20744414146415346',NULL,X'',X'',X'');"
2491 "INSERT INTO 'metas' VALUES(14,692,692,11,0,"
2492 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6',0,0,0,0,0,0"
2493 ",'The WebKit Open Source Project','The WebKit Open Source Project',NU"
2494 "LL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F72672F1204504E475"
2495 "8',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259"
2496 "',NULL,X'',X'',X'');"
2497 "CREATE TABLE deleted_metas (metahandle bigint primary key ON CONFLICT"
2498 " FAIL,base_version bigint default -1,server_version bigint default 0,"
2499 "local_external_id bigint default 0,transaction_version bigint default"
2500 " 0,mtime bigint default 0,server_mtime bigint default 0,ctime bigint "
2501 "default 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
2502 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defau"
2503 "lt 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
2504 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,s"
2505 "erver_is_del bit default 0,non_unique_name varchar,server_non_unique_"
2506 "name varchar(255),unique_server_tag varchar,unique_client_tag varchar"
2507 ",specifics blob,server_specifics blob,base_server_specifics blob,serv"
2508 "er_unique_position blob,unique_position blob,unique_bookmark_tag blob"
2510 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birt"
2511 "hday TEXT, db_create_version TEXT, db_create_time INT, next_id INT de"
2512 "fault -2, cache_guid TEXT, notification_state BLOB, bag_of_chips BLOB"
2514 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.or"
2515 "g','c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-13107"
2516 "8,'9010788312004066376x-6609234393368420856x',NULL,NULL);"));
2517 ASSERT_TRUE(connection
->CommitTransaction());
2520 TEST_F(DirectoryBackingStoreTest
, MigrateVersion67To68
) {
2521 sql::Connection connection
;
2522 ASSERT_TRUE(connection
.OpenInMemory());
2524 SetUpVersion67Database(&connection
);
2526 // Columns existing before version 67.
2527 ASSERT_TRUE(connection
.DoesColumnExist("metas", "name"));
2528 ASSERT_TRUE(connection
.DoesColumnExist("metas", "unsanitized_name"));
2529 ASSERT_TRUE(connection
.DoesColumnExist("metas", "server_name"));
2531 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2532 new TestDirectoryBackingStore(GetUsername(), &connection
));
2534 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2535 ASSERT_TRUE(dbs
->MigrateVersion67To68());
2536 ASSERT_EQ(68, dbs
->GetVersion());
2537 ASSERT_TRUE(dbs
->needs_column_refresh_
);
2540 TEST_F(DirectoryBackingStoreTest
, MigrateVersion68To69
) {
2541 sql::Connection connection
;
2542 ASSERT_TRUE(connection
.OpenInMemory());
2543 SetUpVersion68Database(&connection
);
2546 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2547 new TestDirectoryBackingStore(GetUsername(), &connection
));
2549 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2550 ASSERT_TRUE(dbs
->MigrateVersion68To69());
2551 ASSERT_EQ(69, dbs
->GetVersion());
2552 ASSERT_TRUE(dbs
->needs_column_refresh_
);
2555 ASSERT_TRUE(connection
.DoesColumnExist("metas", "specifics"));
2556 ASSERT_TRUE(connection
.DoesColumnExist("metas", "server_specifics"));
2557 sql::Statement
s(connection
.GetUniqueStatement("SELECT non_unique_name,"
2558 "is_del, is_dir, id, specifics, server_specifics FROM metas "
2559 "WHERE metahandle = 2"));
2560 ASSERT_TRUE(s
.Step());
2561 ASSERT_EQ("Deleted Item", s
.ColumnString(0));
2562 ASSERT_TRUE(s
.ColumnBool(1));
2563 ASSERT_FALSE(s
.ColumnBool(2));
2564 ASSERT_EQ("s_ID_2", s
.ColumnString(3));
2565 sync_pb::EntitySpecifics specifics
;
2566 specifics
.ParseFromArray(s
.ColumnBlob(4), s
.ColumnByteLength(4));
2567 ASSERT_TRUE(specifics
.has_bookmark());
2568 ASSERT_EQ("http://www.google.com/", specifics
.bookmark().url());
2569 ASSERT_EQ("AASGASGA", specifics
.bookmark().favicon());
2570 specifics
.ParseFromArray(s
.ColumnBlob(5), s
.ColumnByteLength(5));
2571 ASSERT_TRUE(specifics
.has_bookmark());
2572 ASSERT_EQ("http://www.google.com/2", specifics
.bookmark().url());
2573 ASSERT_EQ("ASADGADGADG", specifics
.bookmark().favicon());
2574 ASSERT_FALSE(s
.Step());
2577 TEST_F(DirectoryBackingStoreTest
, MigrateVersion69To70
) {
2578 sql::Connection connection
;
2579 ASSERT_TRUE(connection
.OpenInMemory());
2580 SetUpVersion69Database(&connection
);
2582 ASSERT_TRUE(connection
.DoesColumnExist("metas", "singleton_tag"));
2583 ASSERT_FALSE(connection
.DoesColumnExist("metas", "unique_server_tag"));
2584 ASSERT_FALSE(connection
.DoesColumnExist("metas", "unique_client_tag"));
2587 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2588 new TestDirectoryBackingStore(GetUsername(), &connection
));
2590 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2591 ASSERT_TRUE(dbs
->MigrateVersion69To70());
2592 ASSERT_EQ(70, dbs
->GetVersion());
2593 ASSERT_TRUE(dbs
->needs_column_refresh_
);
2596 EXPECT_TRUE(connection
.DoesColumnExist("metas", "unique_server_tag"));
2597 EXPECT_TRUE(connection
.DoesColumnExist("metas", "unique_client_tag"));
2598 sql::Statement
s(connection
.GetUniqueStatement("SELECT id"
2599 " FROM metas WHERE unique_server_tag = 'google_chrome'"));
2600 ASSERT_TRUE(s
.Step());
2601 EXPECT_EQ("s_ID_7", s
.ColumnString(0));
2604 TEST_F(DirectoryBackingStoreTest
, MigrateVersion70To71
) {
2605 sql::Connection connection
;
2606 ASSERT_TRUE(connection
.OpenInMemory());
2607 SetUpVersion70Database(&connection
);
2609 ASSERT_TRUE(connection
.DoesColumnExist("share_info", "last_sync_timestamp"));
2610 ASSERT_TRUE(connection
.DoesColumnExist("share_info", "initial_sync_ended"));
2611 ASSERT_FALSE(connection
.DoesTableExist("models"));
2614 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2615 new TestDirectoryBackingStore(GetUsername(), &connection
));
2617 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2618 ASSERT_TRUE(dbs
->MigrateVersion70To71());
2619 ASSERT_EQ(71, dbs
->GetVersion());
2620 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2623 ASSERT_FALSE(connection
.DoesColumnExist("share_info", "last_sync_timestamp"));
2624 ASSERT_FALSE(connection
.DoesColumnExist("share_info", "initial_sync_ended"));
2625 ASSERT_TRUE(connection
.DoesTableExist("models"));
2626 ASSERT_TRUE(connection
.DoesColumnExist("models", "initial_sync_ended"));
2627 ASSERT_TRUE(connection
.DoesColumnExist("models", "last_download_timestamp"));
2628 ASSERT_TRUE(connection
.DoesColumnExist("models", "model_id"));
2630 sql::Statement
s(connection
.GetUniqueStatement("SELECT model_id, "
2631 "initial_sync_ended, last_download_timestamp FROM models"));
2632 ASSERT_TRUE(s
.Step());
2633 std::string model_id
= s
.ColumnString(0);
2634 EXPECT_EQ("C2881000", base::HexEncode(model_id
.data(), model_id
.size()))
2635 << "Model ID is expected to be the empty BookmarkSpecifics proto.";
2636 EXPECT_TRUE(s
.ColumnBool(1));
2637 EXPECT_EQ(694, s
.ColumnInt64(2));
2638 ASSERT_FALSE(s
.Step());
2642 TEST_F(DirectoryBackingStoreTest
, MigrateVersion71To72
) {
2643 sql::Connection connection
;
2644 ASSERT_TRUE(connection
.OpenInMemory());
2645 SetUpVersion71Database(&connection
);
2647 ASSERT_TRUE(connection
.DoesTableExist("extended_attributes"));
2650 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2651 new TestDirectoryBackingStore(GetUsername(), &connection
));
2653 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2654 ASSERT_TRUE(dbs
->MigrateVersion71To72());
2655 ASSERT_EQ(72, dbs
->GetVersion());
2656 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2659 ASSERT_FALSE(connection
.DoesTableExist("extended_attributes"));
2662 TEST_F(DirectoryBackingStoreTest
, MigrateVersion72To73
) {
2663 sql::Connection connection
;
2664 ASSERT_TRUE(connection
.OpenInMemory());
2665 SetUpVersion72Database(&connection
);
2667 ASSERT_FALSE(connection
.DoesColumnExist("share_info", "notification_state"));
2670 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2671 new TestDirectoryBackingStore(GetUsername(), &connection
));
2673 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2674 ASSERT_TRUE(dbs
->MigrateVersion72To73());
2675 ASSERT_EQ(73, dbs
->GetVersion());
2676 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2679 ASSERT_TRUE(connection
.DoesColumnExist("share_info", "notification_state"));
2682 TEST_F(DirectoryBackingStoreTest
, MigrateVersion73To74
) {
2683 sql::Connection connection
;
2684 ASSERT_TRUE(connection
.OpenInMemory());
2685 SetUpVersion73Database(&connection
);
2688 connection
.DoesColumnExist("share_info", "autofill_migration_state"));
2690 connection
.DoesColumnExist("share_info",
2691 "bookmarks_added_during_autofill_migration"));
2693 connection
.DoesColumnExist("share_info", "autofill_migration_time"));
2695 connection
.DoesColumnExist("share_info",
2696 "autofill_entries_added_during_migration"));
2699 connection
.DoesColumnExist("share_info",
2700 "autofill_profiles_added_during_migration"));
2703 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2704 new TestDirectoryBackingStore(GetUsername(), &connection
));
2706 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2707 ASSERT_TRUE(dbs
->MigrateVersion73To74());
2708 ASSERT_EQ(74, dbs
->GetVersion());
2709 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2713 connection
.DoesColumnExist("share_info", "autofill_migration_state"));
2715 connection
.DoesColumnExist("share_info",
2716 "bookmarks_added_during_autofill_migration"));
2718 connection
.DoesColumnExist("share_info", "autofill_migration_time"));
2720 connection
.DoesColumnExist("share_info",
2721 "autofill_entries_added_during_migration"));
2724 connection
.DoesColumnExist("share_info",
2725 "autofill_profiles_added_during_migration"));
2728 TEST_F(DirectoryBackingStoreTest
, MigrateVersion74To75
) {
2729 sql::Connection connection
;
2730 ASSERT_TRUE(connection
.OpenInMemory());
2731 SetUpVersion74Database(&connection
);
2733 ASSERT_FALSE(connection
.DoesColumnExist("models", "progress_marker"));
2734 ASSERT_TRUE(connection
.DoesColumnExist("models", "last_download_timestamp"));
2737 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2738 new TestDirectoryBackingStore(GetUsername(), &connection
));
2740 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2741 ASSERT_TRUE(dbs
->MigrateVersion74To75());
2742 ASSERT_EQ(75, dbs
->GetVersion());
2743 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2746 ASSERT_TRUE(connection
.DoesColumnExist("models", "progress_marker"));
2747 ASSERT_FALSE(connection
.DoesColumnExist("models", "last_download_timestamp"));
2750 TEST_F(DirectoryBackingStoreTest
, MigrateVersion75To76
) {
2751 sql::Connection connection
;
2752 ASSERT_TRUE(connection
.OpenInMemory());
2753 SetUpVersion75Database(&connection
);
2756 connection
.DoesColumnExist("share_info", "autofill_migration_state"));
2757 ASSERT_TRUE(connection
.DoesColumnExist("share_info",
2758 "bookmarks_added_during_autofill_migration"));
2760 connection
.DoesColumnExist("share_info", "autofill_migration_time"));
2761 ASSERT_TRUE(connection
.DoesColumnExist("share_info",
2762 "autofill_entries_added_during_migration"));
2763 ASSERT_TRUE(connection
.DoesColumnExist("share_info",
2764 "autofill_profiles_added_during_migration"));
2766 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2767 new TestDirectoryBackingStore(GetUsername(), &connection
));
2768 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2769 ASSERT_TRUE(dbs
->MigrateVersion75To76());
2770 ASSERT_EQ(76, dbs
->GetVersion());
2771 ASSERT_TRUE(dbs
->needs_column_refresh_
);
2772 // Cannot actual refresh columns due to version 76 not containing all
2773 // necessary columns.
2776 TEST_F(DirectoryBackingStoreTest
, MigrateVersion76To77
) {
2777 sql::Connection connection
;
2778 ASSERT_TRUE(connection
.OpenInMemory());
2779 SetUpVersion76Database(&connection
);
2781 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2782 new TestDirectoryBackingStore(GetUsername(), &connection
));
2783 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2785 EXPECT_EQ(GetExpectedLegacyMetaProtoTimes(INCLUDE_DELETED_ITEMS
),
2786 GetMetaProtoTimes(dbs
->db_
.get()));
2787 // Since the proto times are expected to be in a legacy format, they may not
2788 // be compatible with ProtoTimeToTime, so we don't call ExpectTimes().
2790 ASSERT_TRUE(dbs
->MigrateVersion76To77());
2791 ASSERT_EQ(77, dbs
->GetVersion());
2793 EXPECT_EQ(GetExpectedMetaProtoTimes(INCLUDE_DELETED_ITEMS
),
2794 GetMetaProtoTimes(dbs
->db_
.get()));
2795 // Cannot actually load entries due to version 77 not having all required
2797 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2800 TEST_F(DirectoryBackingStoreTest
, MigrateVersion77To78
) {
2801 sql::Connection connection
;
2802 ASSERT_TRUE(connection
.OpenInMemory());
2803 SetUpVersion77Database(&connection
);
2805 ASSERT_FALSE(connection
.DoesColumnExist("metas", "BASE_SERVER_SPECIFICS"));
2808 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2809 new TestDirectoryBackingStore(GetUsername(), &connection
));
2810 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2811 ASSERT_TRUE(dbs
->MigrateVersion77To78());
2812 ASSERT_EQ(78, dbs
->GetVersion());
2814 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2817 ASSERT_TRUE(connection
.DoesColumnExist("metas", "base_server_specifics"));
2820 TEST_F(DirectoryBackingStoreTest
, MigrateVersion78To79
) {
2821 const int kInitialNextId
= -65542;
2823 sql::Connection connection
;
2824 ASSERT_TRUE(connection
.OpenInMemory());
2825 SetUpVersion78Database(&connection
);
2827 // Double-check the original next_id is what we think it is.
2828 sql::Statement
s(connection
.GetUniqueStatement(
2829 "SELECT next_id FROM share_info"));
2831 ASSERT_EQ(kInitialNextId
, s
.ColumnInt(0));
2833 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2834 new TestDirectoryBackingStore(GetUsername(), &connection
));
2835 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2836 ASSERT_TRUE(dbs
->MigrateVersion78To79());
2837 ASSERT_EQ(79, dbs
->GetVersion());
2838 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2840 // Ensure the next_id has been incremented.
2841 MetahandlesIndex entry_bucket
;
2842 JournalIndex delete_journals
;;
2843 STLElementDeleter
<MetahandlesIndex
> deleter(&entry_bucket
);
2844 Directory::KernelLoadInfo load_info
;
2847 ASSERT_TRUE(dbs
->Load(&entry_bucket
, &delete_journals
, &load_info
));
2848 EXPECT_LE(load_info
.kernel_info
.next_id
, kInitialNextId
- 65536);
2851 TEST_F(DirectoryBackingStoreTest
, MigrateVersion79To80
) {
2852 sql::Connection connection
;
2853 ASSERT_TRUE(connection
.OpenInMemory());
2854 SetUpVersion79Database(&connection
);
2856 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2857 new TestDirectoryBackingStore(GetUsername(), &connection
));
2858 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2859 ASSERT_TRUE(dbs
->MigrateVersion79To80());
2860 ASSERT_EQ(80, dbs
->GetVersion());
2861 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2863 // Ensure the bag_of_chips has been set.
2864 MetahandlesIndex entry_bucket
;
2865 JournalIndex delete_journals
;;
2866 STLElementDeleter
<MetahandlesIndex
> deleter(&entry_bucket
);
2867 Directory::KernelLoadInfo load_info
;
2869 ASSERT_TRUE(dbs
->Load(&entry_bucket
, &delete_journals
, &load_info
));
2870 // Check that the initial value is the serialization of an empty ChipBag.
2871 sync_pb::ChipBag chip_bag
;
2872 std::string serialized_chip_bag
;
2873 ASSERT_TRUE(chip_bag
.SerializeToString(&serialized_chip_bag
));
2874 EXPECT_EQ(serialized_chip_bag
, load_info
.kernel_info
.bag_of_chips
);
2877 TEST_F(DirectoryBackingStoreTest
, MigrateVersion80To81
) {
2878 sql::Connection connection
;
2879 ASSERT_TRUE(connection
.OpenInMemory());
2880 SetUpVersion80Database(&connection
);
2882 sql::Statement
s(connection
.GetUniqueStatement(
2883 "SELECT metahandle, server_position_in_parent "
2884 "FROM metas WHERE unique_server_tag = 'google_chrome'"));
2885 ASSERT_TRUE(s
.Step());
2886 ASSERT_EQ(sql::COLUMN_TYPE_INTEGER
, s
.ColumnType(1));
2888 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2889 new TestDirectoryBackingStore(GetUsername(), &connection
));
2890 ASSERT_TRUE(dbs
->MigrateVersion80To81());
2891 ASSERT_EQ(81, dbs
->GetVersion());
2893 // Test that ordinal values are preserved correctly.
2894 sql::Statement
new_s(connection
.GetUniqueStatement(
2895 "SELECT metahandle, server_ordinal_in_parent "
2896 "FROM metas WHERE unique_server_tag = 'google_chrome'"));
2897 ASSERT_TRUE(new_s
.Step());
2898 ASSERT_EQ(sql::COLUMN_TYPE_BLOB
, new_s
.ColumnType(1));
2900 std::string expected_ordinal
= Int64ToNodeOrdinal(1048576).ToInternalValue();
2901 std::string actual_ordinal
;
2902 new_s
.ColumnBlobAsString(1, &actual_ordinal
);
2903 ASSERT_EQ(expected_ordinal
, actual_ordinal
);
2906 TEST_F(DirectoryBackingStoreTest
, MigrateVersion81To82
) {
2907 sql::Connection connection
;
2908 ASSERT_TRUE(connection
.OpenInMemory());
2909 SetUpVersion81Database(&connection
);
2910 ASSERT_FALSE(connection
.DoesColumnExist("models", "transaction_version"));
2912 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2913 new TestDirectoryBackingStore(GetUsername(), &connection
));
2914 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2915 ASSERT_TRUE(dbs
->MigrateVersion81To82());
2916 ASSERT_EQ(82, dbs
->GetVersion());
2917 ASSERT_FALSE(dbs
->needs_column_refresh_
);
2919 ASSERT_TRUE(connection
.DoesColumnExist("models", "transaction_version"));
2922 TEST_F(DirectoryBackingStoreTest
, MigrateVersion82To83
) {
2923 sql::Connection connection
;
2924 ASSERT_TRUE(connection
.OpenInMemory());
2925 SetUpVersion82Database(&connection
);
2926 ASSERT_FALSE(connection
.DoesColumnExist("metas", "transaction_version"));
2928 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2929 new TestDirectoryBackingStore(GetUsername(), &connection
));
2930 ASSERT_TRUE(dbs
->MigrateVersion82To83());
2931 ASSERT_EQ(83, dbs
->GetVersion());
2933 ASSERT_TRUE(connection
.DoesColumnExist("metas", "transaction_version"));
2936 TEST_F(DirectoryBackingStoreTest
, MigrateVersion83To84
) {
2937 sql::Connection connection
;
2938 ASSERT_TRUE(connection
.OpenInMemory());
2939 SetUpVersion83Database(&connection
);
2940 ASSERT_FALSE(connection
.DoesTableExist("deleted_metas"));
2942 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2943 new TestDirectoryBackingStore(GetUsername(), &connection
));
2944 ASSERT_TRUE(dbs
->MigrateVersion83To84());
2945 ASSERT_EQ(84, dbs
->GetVersion());
2947 ASSERT_TRUE(connection
.DoesTableExist("deleted_metas"));
2950 TEST_F(DirectoryBackingStoreTest
, MigrateVersion84To85
) {
2951 sql::Connection connection
;
2952 ASSERT_TRUE(connection
.OpenInMemory());
2953 SetUpVersion84Database(&connection
);
2954 ASSERT_TRUE(connection
.DoesColumnExist("models", "initial_sync_ended"));
2956 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2957 new TestDirectoryBackingStore(GetUsername(), &connection
));
2958 ASSERT_TRUE(dbs
->MigrateVersion84To85());
2959 ASSERT_EQ(85, dbs
->GetVersion());
2960 ASSERT_FALSE(connection
.DoesColumnExist("models", "initial_sync_ended"));
2963 TEST_F(DirectoryBackingStoreTest
, MigrateVersion85To86
) {
2964 sql::Connection connection
;
2965 ASSERT_TRUE(connection
.OpenInMemory());
2966 SetUpVersion85Database(&connection
);
2967 EXPECT_TRUE(connection
.DoesColumnExist("metas", "next_id"));
2968 EXPECT_TRUE(connection
.DoesColumnExist("metas", "prev_id"));
2969 EXPECT_TRUE(connection
.DoesColumnExist("metas", "server_ordinal_in_parent"));
2970 EXPECT_FALSE(connection
.DoesColumnExist("metas", "unique_position"));
2971 EXPECT_FALSE(connection
.DoesColumnExist("metas", "server_unique_position"));
2972 EXPECT_FALSE(connection
.DoesColumnExist("metas", "unique_bookmark_tag"));
2974 scoped_ptr
<TestDirectoryBackingStore
> dbs(
2975 new TestDirectoryBackingStore(GetUsername(), &connection
));
2976 ASSERT_TRUE(dbs
->MigrateVersion85To86());
2977 EXPECT_EQ(86, dbs
->GetVersion());
2978 EXPECT_TRUE(connection
.DoesColumnExist("metas", "unique_position"));
2979 EXPECT_TRUE(connection
.DoesColumnExist("metas", "server_unique_position"));
2980 EXPECT_TRUE(connection
.DoesColumnExist("metas", "unique_bookmark_tag"));
2981 ASSERT_TRUE(dbs
->needs_column_refresh_
);
2982 ASSERT_TRUE(dbs
->RefreshColumns());
2983 EXPECT_FALSE(connection
.DoesColumnExist("metas", "next_id"));
2984 EXPECT_FALSE(connection
.DoesColumnExist("metas", "prev_id"));
2985 EXPECT_FALSE(connection
.DoesColumnExist("metas", "server_ordinal_in_parent"));
2988 MetahandlesIndex metas
;
2989 STLElementDeleter
<MetahandlesIndex
> deleter(&metas
);
2990 dbs
->LoadEntries(&metas
);
2994 // Grab a bookmark and examine it.
2995 needle
.put(META_HANDLE
, 5);
2996 MetahandlesIndex::iterator i
= metas
.find(&needle
);
2997 ASSERT_FALSE(i
== metas
.end());
2998 EntryKernel
* bm
= *i
;
2999 ASSERT_EQ(bm
->ref(ID
).value(), "s_ID_5");
3001 EXPECT_TRUE(bm
->ref(UNIQUE_POSITION
).IsValid());
3002 EXPECT_TRUE(bm
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3003 EXPECT_EQ(UniquePosition::kSuffixLength
,
3004 bm
->ref(UNIQUE_BOOKMARK_TAG
).length());
3006 // Grab a non-bookmark and examine it.
3007 needle
.put(META_HANDLE
, 1);
3008 MetahandlesIndex::iterator j
= metas
.find(&needle
);
3009 ASSERT_FALSE(j
== metas
.end());
3010 EntryKernel
* root
= *j
;
3011 ASSERT_EQ(root
->ref(ID
).value(), "r");
3013 EXPECT_FALSE(root
->ref(UNIQUE_POSITION
).IsValid());
3014 EXPECT_FALSE(root
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3015 EXPECT_TRUE(root
->ref(UNIQUE_BOOKMARK_TAG
).empty());
3017 // Make sure we didn't mistake the bookmark root node for a real bookmark.
3018 needle
.put(META_HANDLE
, 8);
3019 MetahandlesIndex::iterator k
= metas
.find(&needle
);
3020 ASSERT_FALSE(k
== metas
.end());
3021 EntryKernel
* bm_root
= *k
;
3022 ASSERT_EQ(bm_root
->ref(ID
).value(), "s_ID_8");
3023 ASSERT_EQ(bm_root
->ref(UNIQUE_SERVER_TAG
), "google_chrome_bookmarks");
3025 EXPECT_FALSE(bm_root
->ref(UNIQUE_POSITION
).IsValid());
3026 EXPECT_FALSE(bm_root
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3027 EXPECT_TRUE(bm_root
->ref(UNIQUE_BOOKMARK_TAG
).empty());
3029 // Make sure we didn't assign positions to server-created folders, either.
3030 needle
.put(META_HANDLE
, 10);
3031 MetahandlesIndex::iterator l
= metas
.find(&needle
);
3032 ASSERT_FALSE(l
== metas
.end());
3033 EntryKernel
* perm_folder
= *l
;
3034 ASSERT_EQ(perm_folder
->ref(ID
).value(), "s_ID_10");
3035 ASSERT_EQ(perm_folder
->ref(UNIQUE_SERVER_TAG
), "other_bookmarks");
3037 EXPECT_FALSE(perm_folder
->ref(UNIQUE_POSITION
).IsValid());
3038 EXPECT_FALSE(perm_folder
->ref(SERVER_UNIQUE_POSITION
).IsValid());
3039 EXPECT_TRUE(perm_folder
->ref(UNIQUE_BOOKMARK_TAG
).empty());
3041 // Make sure that the syncable::Directory and the migration code agree on
3042 // which items should or should not have unique position values. This test
3043 // may become obsolete if the directory's definition of that function
3044 // changes, but, until then, this is a useful test.
3045 for (MetahandlesIndex::iterator it
= metas
.begin();
3046 it
!= metas
.end(); it
++) {
3047 SCOPED_TRACE((*it
)->ref(ID
));
3048 if ((*it
)->ShouldMaintainPosition()) {
3049 EXPECT_TRUE((*it
)->ref(UNIQUE_POSITION
).IsValid());
3050 EXPECT_TRUE((*it
)->ref(SERVER_UNIQUE_POSITION
).IsValid());
3051 EXPECT_FALSE((*it
)->ref(UNIQUE_BOOKMARK_TAG
).empty());
3053 EXPECT_FALSE((*it
)->ref(UNIQUE_POSITION
).IsValid());
3054 EXPECT_FALSE((*it
)->ref(SERVER_UNIQUE_POSITION
).IsValid());
3055 EXPECT_TRUE((*it
)->ref(UNIQUE_BOOKMARK_TAG
).empty());
3061 TEST_F(DirectoryBackingStoreTest
, DetectInvalidPosition
) {
3062 sql::Connection connection
;
3063 ASSERT_TRUE(connection
.OpenInMemory());
3064 SetUpVersion86Database(&connection
);
3066 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3067 new TestDirectoryBackingStore(GetUsername(), &connection
));
3068 ASSERT_EQ(86, dbs
->GetVersion());
3070 // Insert row with bad position.
3071 sql::Statement
s(connection
.GetUniqueStatement(
3072 "INSERT INTO metas "
3073 "( id, metahandle, is_dir, ctime, mtime,"
3074 " unique_position, server_unique_position) "
3075 "VALUES('c-invalid', 9999, 1, 0, 0, 'BAD_POS', 'BAD_POS')"));
3076 ASSERT_TRUE(s
.Run());
3078 // Trying to unpack this entry should signal that the DB is corrupted.
3079 MetahandlesIndex entry_bucket
;
3080 JournalIndex delete_journals
;;
3081 STLElementDeleter
<MetahandlesIndex
> deleter(&entry_bucket
);
3082 Directory::KernelLoadInfo kernel_load_info
;
3083 ASSERT_EQ(FAILED_DATABASE_CORRUPT
,
3084 dbs
->Load(&entry_bucket
, &delete_journals
, &kernel_load_info
));
3087 TEST_P(MigrationTest
, ToCurrentVersion
) {
3088 sql::Connection connection
;
3089 ASSERT_TRUE(connection
.OpenInMemory());
3090 switch (GetParam()) {
3092 SetUpVersion67Database(&connection
);
3095 SetUpVersion68Database(&connection
);
3098 SetUpVersion69Database(&connection
);
3101 SetUpVersion70Database(&connection
);
3104 SetUpVersion71Database(&connection
);
3107 SetUpVersion72Database(&connection
);
3110 SetUpVersion73Database(&connection
);
3113 SetUpVersion74Database(&connection
);
3116 SetUpVersion75Database(&connection
);
3119 SetUpVersion76Database(&connection
);
3122 SetUpVersion77Database(&connection
);
3125 SetUpVersion78Database(&connection
);
3128 SetUpVersion79Database(&connection
);
3131 SetUpVersion80Database(&connection
);
3134 SetUpVersion81Database(&connection
);
3137 SetUpVersion82Database(&connection
);
3140 SetUpVersion83Database(&connection
);
3143 SetUpVersion84Database(&connection
);
3146 SetUpVersion85Database(&connection
);
3149 SetUpVersion86Database(&connection
);
3152 // If you see this error, it may mean that you've increased the
3153 // database version number but you haven't finished adding unit tests
3154 // for the database migration code. You need to need to supply a
3155 // SetUpVersionXXDatabase function with a dump of the test database
3156 // at the old schema. Here's one way to do that:
3157 // 1. Start on a clean tree (with none of your pending schema changes).
3158 // 2. Set a breakpoint in this function and run the unit test.
3159 // 3. Allow this test to run to completion (step out of the call),
3160 // without allowing ~MigrationTest to execute.
3161 // 4. Examine this->temp_dir_ to determine the location of the
3162 // test database (it is currently of the version you need).
3163 // 5. Dump this using the sqlite3 command line tool:
3164 // > .output foo_dump.sql
3166 // 6. Replace the timestamp columns with META_PROTO_TIMES(x) (or
3167 // LEGACY_META_PROTO_TIMES(x) if before Version 77).
3168 FAIL() << "Need to supply database dump for version " << GetParam();
3171 syncable::Directory::KernelLoadInfo dir_info
;
3172 MetahandlesIndex index
;
3173 JournalIndex delete_journals
;;
3174 STLElementDeleter
<MetahandlesIndex
> index_deleter(&index
);
3177 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3178 new TestDirectoryBackingStore(GetUsername(), &connection
));
3179 ASSERT_EQ(OPENED
, dbs
->Load(&index
, &delete_journals
, &dir_info
));
3180 ASSERT_FALSE(dbs
->needs_column_refresh_
);
3181 ASSERT_EQ(kCurrentDBVersion
, dbs
->GetVersion());
3184 // Columns deleted in Version 67.
3185 ASSERT_FALSE(connection
.DoesColumnExist("metas", "name"));
3186 ASSERT_FALSE(connection
.DoesColumnExist("metas", "unsanitized_name"));
3187 ASSERT_FALSE(connection
.DoesColumnExist("metas", "server_name"));
3189 // Columns added in Version 68.
3190 ASSERT_TRUE(connection
.DoesColumnExist("metas", "specifics"));
3191 ASSERT_TRUE(connection
.DoesColumnExist("metas", "server_specifics"));
3193 // Columns deleted in Version 68.
3194 ASSERT_FALSE(connection
.DoesColumnExist("metas", "is_bookmark_object"));
3195 ASSERT_FALSE(connection
.DoesColumnExist("metas",
3196 "server_is_bookmark_object"));
3197 ASSERT_FALSE(connection
.DoesColumnExist("metas", "bookmark_favicon"));
3198 ASSERT_FALSE(connection
.DoesColumnExist("metas", "bookmark_url"));
3199 ASSERT_FALSE(connection
.DoesColumnExist("metas", "server_bookmark_url"));
3201 // Renamed a column in Version 70
3202 ASSERT_FALSE(connection
.DoesColumnExist("metas", "singleton_tag"));
3203 ASSERT_TRUE(connection
.DoesColumnExist("metas", "unique_server_tag"));
3204 ASSERT_TRUE(connection
.DoesColumnExist("metas", "unique_client_tag"));
3206 // Removed extended attributes in Version 72.
3207 ASSERT_FALSE(connection
.DoesTableExist("extended_attributes"));
3209 // Columns added in Version 73.
3210 ASSERT_TRUE(connection
.DoesColumnExist("share_info", "notification_state"));
3212 // Column replaced in version 75.
3213 ASSERT_TRUE(connection
.DoesColumnExist("models", "progress_marker"));
3214 ASSERT_FALSE(connection
.DoesColumnExist("models", "last_download_timestamp"));
3216 // Columns removed in version 76.
3218 connection
.DoesColumnExist("share_info", "autofill_migration_state"));
3219 ASSERT_FALSE(connection
.DoesColumnExist("share_info",
3220 "bookmarks_added_during_autofill_migration"));
3222 connection
.DoesColumnExist("share_info", "autofill_migration_time"));
3223 ASSERT_FALSE(connection
.DoesColumnExist("share_info",
3224 "autofill_entries_added_during_migration"));
3225 ASSERT_FALSE(connection
.DoesColumnExist("share_info",
3226 "autofill_profiles_added_during_migration"));
3228 // Column added in version 78.
3229 ASSERT_TRUE(connection
.DoesColumnExist("metas", "base_server_specifics"));
3231 // Column added in version 82.
3232 ASSERT_TRUE(connection
.DoesColumnExist("models", "transaction_version"));
3234 // Column added in version 83.
3235 ASSERT_TRUE(connection
.DoesColumnExist("metas", "transaction_version"));
3237 // Table added in version 84.
3238 ASSERT_TRUE(connection
.DoesTableExist("deleted_metas"));
3240 // Column removed in version 85.
3241 ASSERT_FALSE(connection
.DoesColumnExist("models", "initial_sync_ended"));
3243 // Check download_progress state (v75 migration)
3245 dir_info
.kernel_info
.download_progress
[BOOKMARKS
]
3246 .timestamp_token_for_migration());
3248 dir_info
.kernel_info
.download_progress
[BOOKMARKS
]
3251 dir_info
.kernel_info
.download_progress
[BOOKMARKS
]
3254 dir_info
.kernel_info
.download_progress
[THEMES
]
3255 .has_timestamp_token_for_migration());
3257 dir_info
.kernel_info
.download_progress
[THEMES
]
3260 dir_info
.kernel_info
.download_progress
[THEMES
]
3263 dir_info
.kernel_info
.download_progress
[THEMES
]
3267 EXPECT_EQ(GetExpectedMetaProtoTimes(DONT_INCLUDE_DELETED_ITEMS
),
3268 GetMetaProtoTimes(&connection
));
3269 ExpectTimes(index
, GetExpectedMetaTimes());
3271 MetahandlesIndex::iterator it
= index
.begin();
3272 ASSERT_TRUE(it
!= index
.end());
3273 ASSERT_EQ(1, (*it
)->ref(META_HANDLE
));
3274 EXPECT_TRUE((*it
)->ref(ID
).IsRoot());
3276 ASSERT_TRUE(++it
!= index
.end());
3277 ASSERT_EQ(6, (*it
)->ref(META_HANDLE
));
3278 EXPECT_TRUE((*it
)->ref(IS_DIR
));
3279 EXPECT_TRUE((*it
)->ref(SERVER_IS_DIR
));
3281 (*it
)->ref(SPECIFICS
).bookmark().has_url());
3283 (*it
)->ref(SERVER_SPECIFICS
).bookmark().has_url());
3285 (*it
)->ref(SPECIFICS
).bookmark().has_favicon());
3286 EXPECT_FALSE((*it
)->ref(SERVER_SPECIFICS
).bookmark().has_favicon());
3288 ASSERT_TRUE(++it
!= index
.end());
3289 ASSERT_EQ(7, (*it
)->ref(META_HANDLE
));
3290 EXPECT_EQ("google_chrome", (*it
)->ref(UNIQUE_SERVER_TAG
));
3291 EXPECT_FALSE((*it
)->ref(SPECIFICS
).has_bookmark());
3292 EXPECT_FALSE((*it
)->ref(SERVER_SPECIFICS
).has_bookmark());
3294 ASSERT_TRUE(++it
!= index
.end());
3295 ASSERT_EQ(8, (*it
)->ref(META_HANDLE
));
3296 EXPECT_EQ("google_chrome_bookmarks", (*it
)->ref(UNIQUE_SERVER_TAG
));
3297 EXPECT_TRUE((*it
)->ref(SPECIFICS
).has_bookmark());
3298 EXPECT_TRUE((*it
)->ref(SERVER_SPECIFICS
).has_bookmark());
3300 ASSERT_TRUE(++it
!= index
.end());
3301 ASSERT_EQ(9, (*it
)->ref(META_HANDLE
));
3302 EXPECT_EQ("bookmark_bar", (*it
)->ref(UNIQUE_SERVER_TAG
));
3303 EXPECT_TRUE((*it
)->ref(SPECIFICS
).has_bookmark());
3304 EXPECT_TRUE((*it
)->ref(SERVER_SPECIFICS
).has_bookmark());
3306 ASSERT_TRUE(++it
!= index
.end());
3307 ASSERT_EQ(10, (*it
)->ref(META_HANDLE
));
3308 EXPECT_FALSE((*it
)->ref(IS_DEL
));
3309 EXPECT_TRUE((*it
)->ref(SPECIFICS
).has_bookmark());
3310 EXPECT_TRUE((*it
)->ref(SERVER_SPECIFICS
).has_bookmark());
3311 EXPECT_FALSE((*it
)->ref(SPECIFICS
).bookmark().has_url());
3313 (*it
)->ref(SPECIFICS
).bookmark().has_favicon());
3315 (*it
)->ref(SERVER_SPECIFICS
).bookmark().has_url());
3316 EXPECT_FALSE((*it
)->ref(SERVER_SPECIFICS
).bookmark().has_favicon());
3317 EXPECT_EQ("other_bookmarks", (*it
)->ref(UNIQUE_SERVER_TAG
));
3318 EXPECT_EQ("Other Bookmarks", (*it
)->ref(NON_UNIQUE_NAME
));
3319 EXPECT_EQ("Other Bookmarks", (*it
)->ref(SERVER_NON_UNIQUE_NAME
));
3321 ASSERT_TRUE(++it
!= index
.end());
3322 ASSERT_EQ(11, (*it
)->ref(META_HANDLE
));
3323 EXPECT_FALSE((*it
)->ref(IS_DEL
));
3324 EXPECT_FALSE((*it
)->ref(IS_DIR
));
3325 EXPECT_TRUE((*it
)->ref(SPECIFICS
).has_bookmark());
3326 EXPECT_TRUE((*it
)->ref(SERVER_SPECIFICS
).has_bookmark());
3327 EXPECT_EQ("http://dev.chromium.org/",
3328 (*it
)->ref(SPECIFICS
).bookmark().url());
3330 (*it
)->ref(SPECIFICS
).bookmark().favicon());
3331 EXPECT_EQ("http://dev.chromium.org/other",
3332 (*it
)->ref(SERVER_SPECIFICS
).bookmark().url());
3333 EXPECT_EQ("AFAGVASF",
3334 (*it
)->ref(SERVER_SPECIFICS
).bookmark().favicon());
3335 EXPECT_EQ("", (*it
)->ref(UNIQUE_SERVER_TAG
));
3336 EXPECT_EQ("Home (The Chromium Projects)", (*it
)->ref(NON_UNIQUE_NAME
));
3337 EXPECT_EQ("Home (The Chromium Projects)", (*it
)->ref(SERVER_NON_UNIQUE_NAME
));
3339 ASSERT_TRUE(++it
!= index
.end());
3340 ASSERT_EQ(12, (*it
)->ref(META_HANDLE
));
3341 EXPECT_FALSE((*it
)->ref(IS_DEL
));
3342 EXPECT_TRUE((*it
)->ref(IS_DIR
));
3343 EXPECT_EQ("Extra Bookmarks", (*it
)->ref(NON_UNIQUE_NAME
));
3344 EXPECT_EQ("Extra Bookmarks", (*it
)->ref(SERVER_NON_UNIQUE_NAME
));
3345 EXPECT_TRUE((*it
)->ref(SPECIFICS
).has_bookmark());
3346 EXPECT_TRUE((*it
)->ref(SERVER_SPECIFICS
).has_bookmark());
3348 (*it
)->ref(SPECIFICS
).bookmark().has_url());
3350 (*it
)->ref(SERVER_SPECIFICS
).bookmark().has_url());
3352 (*it
)->ref(SPECIFICS
).bookmark().has_favicon());
3353 EXPECT_FALSE((*it
)->ref(SERVER_SPECIFICS
).bookmark().has_favicon());
3355 ASSERT_TRUE(++it
!= index
.end());
3356 ASSERT_EQ(13, (*it
)->ref(META_HANDLE
));
3358 ASSERT_TRUE(++it
!= index
.end());
3359 ASSERT_EQ(14, (*it
)->ref(META_HANDLE
));
3361 ASSERT_TRUE(++it
== index
.end());
3364 INSTANTIATE_TEST_CASE_P(DirectoryBackingStore
, MigrationTest
,
3365 testing::Range(67, kCurrentDBVersion
+ 1));
3367 TEST_F(DirectoryBackingStoreTest
, ModelTypeIds
) {
3368 ModelTypeSet protocol_types
= ProtocolTypes();
3369 for (ModelTypeSet::Iterator iter
= protocol_types
.First(); iter
.Good();
3371 std::string model_id
=
3372 TestDirectoryBackingStore::ModelTypeEnumToModelId(iter
.Get());
3373 EXPECT_EQ(iter
.Get(),
3374 TestDirectoryBackingStore::ModelIdToModelTypeEnum(model_id
.data(),
3381 class OnDiskDirectoryBackingStoreForTest
: public OnDiskDirectoryBackingStore
{
3383 OnDiskDirectoryBackingStoreForTest(const std::string
& dir_name
,
3384 const base::FilePath
& backing_filepath
);
3385 virtual ~OnDiskDirectoryBackingStoreForTest();
3386 bool DidFailFirstOpenAttempt();
3389 virtual void ReportFirstTryOpenFailure() OVERRIDE
;
3392 bool first_open_failed_
;
3395 OnDiskDirectoryBackingStoreForTest::OnDiskDirectoryBackingStoreForTest(
3396 const std::string
& dir_name
,
3397 const base::FilePath
& backing_filepath
) :
3398 OnDiskDirectoryBackingStore(dir_name
, backing_filepath
),
3399 first_open_failed_(false) { }
3401 OnDiskDirectoryBackingStoreForTest::~OnDiskDirectoryBackingStoreForTest() { }
3403 void OnDiskDirectoryBackingStoreForTest::ReportFirstTryOpenFailure() {
3404 // Do nothing, just like we would in release-mode. In debug mode, we DCHECK.
3405 first_open_failed_
= true;
3408 bool OnDiskDirectoryBackingStoreForTest::DidFailFirstOpenAttempt() {
3409 return first_open_failed_
;
3414 // This is a whitebox test intended to exercise the code path where the on-disk
3415 // directory load code decides to delete the current directory and start fresh.
3417 // This is considered "minor" corruption because the database recreation is
3418 // expected to succeed. The alternative, where recreation does not succeed (ie.
3419 // due to read-only file system), is not tested here.
3420 TEST_F(DirectoryBackingStoreTest
, MinorCorruption
) {
3422 scoped_ptr
<OnDiskDirectoryBackingStore
> dbs(
3423 new OnDiskDirectoryBackingStore(GetUsername(), GetDatabasePath()));
3424 EXPECT_TRUE(LoadAndIgnoreReturnedData(dbs
.get()));
3427 // Corrupt the root node.
3429 sql::Connection connection
;
3430 ASSERT_TRUE(connection
.Open(GetDatabasePath()));
3431 ASSERT_TRUE(connection
.Execute(
3432 "UPDATE metas SET parent_id='bogus' WHERE id = 'r';"));
3436 scoped_ptr
<OnDiskDirectoryBackingStoreForTest
> dbs(
3437 new OnDiskDirectoryBackingStoreForTest(GetUsername(),
3438 GetDatabasePath()));
3440 EXPECT_TRUE(LoadAndIgnoreReturnedData(dbs
.get()));
3441 EXPECT_TRUE(dbs
->DidFailFirstOpenAttempt());
3445 TEST_F(DirectoryBackingStoreTest
, DeleteEntries
) {
3446 sql::Connection connection
;
3447 ASSERT_TRUE(connection
.OpenInMemory());
3449 SetUpCurrentDatabaseAndCheckVersion(&connection
);
3450 scoped_ptr
<TestDirectoryBackingStore
> dbs(
3451 new TestDirectoryBackingStore(GetUsername(), &connection
));
3452 MetahandlesIndex index
;
3453 JournalIndex delete_journals
;
3454 Directory::KernelLoadInfo kernel_load_info
;
3455 STLElementDeleter
<MetahandlesIndex
> index_deleter(&index
);
3457 dbs
->Load(&index
, &delete_journals
, &kernel_load_info
);
3458 size_t initial_size
= index
.size();
3459 ASSERT_LT(0U, initial_size
) << "Test requires entries to delete.";
3460 int64 first_to_die
= (*index
.begin())->ref(META_HANDLE
);
3461 MetahandleSet to_delete
;
3462 to_delete
.insert(first_to_die
);
3463 EXPECT_TRUE(dbs
->DeleteEntries(TestDirectoryBackingStore::METAS_TABLE
,
3466 STLDeleteElements(&index
);
3467 dbs
->LoadEntries(&index
);
3469 EXPECT_EQ(initial_size
- 1, index
.size());
3470 bool delete_failed
= false;
3471 for (MetahandlesIndex::iterator it
= index
.begin(); it
!= index
.end();
3473 if ((*it
)->ref(META_HANDLE
) == first_to_die
) {
3474 delete_failed
= true;
3478 EXPECT_FALSE(delete_failed
);
3481 for (MetahandlesIndex::iterator it
= index
.begin(); it
!= index
.end();
3483 to_delete
.insert((*it
)->ref(META_HANDLE
));
3486 EXPECT_TRUE(dbs
->DeleteEntries(TestDirectoryBackingStore::METAS_TABLE
,
3489 STLDeleteElements(&index
);
3490 dbs
->LoadEntries(&index
);
3491 EXPECT_EQ(0U, index
.size());
3494 TEST_F(DirectoryBackingStoreTest
, GenerateCacheGUID
) {
3495 const std::string
& guid1
= TestDirectoryBackingStore::GenerateCacheGUID();
3496 const std::string
& guid2
= TestDirectoryBackingStore::GenerateCacheGUID();
3497 EXPECT_EQ(24U, guid1
.size());
3498 EXPECT_EQ(24U, guid2
.size());
3499 // In theory this test can fail, but it won't before the universe
3500 // dies of heat death.
3501 EXPECT_NE(guid1
, guid2
);
3504 } // namespace syncable
3505 } // namespace syncer