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