Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / sync / syncable / directory_backing_store.cc
index 55a01e6..6d08b75 100644 (file)
@@ -35,7 +35,7 @@ namespace syncable {
 static const string::size_type kUpdateStatementBufferSize = 2048;
 
 // Increment this version whenever updating DB tables.
-const int32 kCurrentDBVersion = 88;
+const int32 kCurrentDBVersion = 89;
 
 // Iterate over the fields of |entry| and bind each to |statement| for
 // updating.  Returns the number of args bound.
@@ -443,6 +443,12 @@ bool DirectoryBackingStore::InitializeTables() {
       version_on_disk = 88;
   }
 
+  // Version 89 migration adds server attachment metadata to the metas table.
+  if (version_on_disk == 88) {
+    if (MigrateVersion88To89())
+      version_on_disk = 89;
+  }
+
   // 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.
@@ -1326,6 +1332,18 @@ bool DirectoryBackingStore::MigrateVersion87To88() {
   return true;
 }
 
+bool DirectoryBackingStore::MigrateVersion88To89() {
+  // Version 89 adds server_attachment_metadata.
+  if (!db_->Execute(
+          "ALTER TABLE metas ADD COLUMN "
+          "server_attachment_metadata BLOB")) {
+    return false;
+  }
+  SetVersion(89);
+  needs_column_refresh_ = true;
+  return true;
+}
+
 bool DirectoryBackingStore::CreateTables() {
   DVLOG(1) << "First run, creating tables";
   // Create two little tables share_version and share_info