Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Unified Diff: sync/syncable/directory_backing_store.cc

Issue 11341048: Populate versions on individual nodes in sync model and native bookmark model. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to head Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/syncable/directory_backing_store.h ('k') | sync/syncable/directory_backing_store_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/syncable/directory_backing_store.cc
diff --git a/sync/syncable/directory_backing_store.cc b/sync/syncable/directory_backing_store.cc
index 4f9febf3c4de725cb27aa0268bfa26947916a7f9..e9ba0acc57c0bd945b1010f3f230a288f64999cb 100644
--- a/sync/syncable/directory_backing_store.cc
+++ b/sync/syncable/directory_backing_store.cc
@@ -40,7 +40,7 @@ static const string::size_type kUpdateStatementBufferSize = 2048;
// Increment this version whenever updating DB tables.
extern const int32 kCurrentDBVersion; // Global visibility for our unittest.
-const int32 kCurrentDBVersion = 82;
+const int32 kCurrentDBVersion = 83;
// Iterate over the fields of |entry| and bind each to |statement| for
// updating. Returns the number of args bound.
@@ -358,6 +358,12 @@ bool DirectoryBackingStore::InitializeTables() {
version_on_disk = 82;
}
+ // Version 83 migration added transaction_version column per sync entry.
+ if (version_on_disk == 82) {
+ if (MigrateVersion82To83())
+ version_on_disk = 83;
+ }
+
// If one of the migrations requested it, drop columns that aren't current.
// It's only safe to do this after migrating all the way to the current
// version.
@@ -1072,6 +1078,19 @@ bool DirectoryBackingStore::MigrateVersion81To82() {
return true;
}
+bool DirectoryBackingStore::MigrateVersion82To83() {
+ // Version 83 added transaction_version on sync node.
+ if (!db_->Execute(
+ "ALTER TABLE metas ADD COLUMN transaction_version BIGINT default 0"))
+ return false;
+ sql::Statement update(db_->GetUniqueStatement(
+ "UPDATE metas SET transaction_version = 0"));
+ if (!update.Run())
+ return false;
+ SetVersion(83);
+ return true;
+}
+
bool DirectoryBackingStore::CreateTables() {
DVLOG(1) << "First run, creating tables";
// Create two little tables share_version and share_info
« no previous file with comments | « sync/syncable/directory_backing_store.h ('k') | sync/syncable/directory_backing_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698