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