diff OrthancServer/DatabaseWrapper.cpp @ 1664:0c58f189782d db-changes

prepare migration to db v6
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 30 Sep 2015 13:43:20 +0200
parents c40fe92a68e7
children 761a5c07fb1b
line wrap: on
line diff
--- a/OrthancServer/DatabaseWrapper.cpp	Wed Sep 30 13:36:30 2015 +0200
+++ b/OrthancServer/DatabaseWrapper.cpp	Wed Sep 30 13:43:20 2015 +0200
@@ -836,18 +836,40 @@
   }
 
 
+  void DatabaseWrapper::ExecuteUpgrade5To6(IStorageArea& storageArea)
+  {
+    printf("ICI\n");
+
+    std::auto_ptr<SQLite::ITransaction> transaction(StartTransaction());
+    transaction->Begin();
+
+    std::list<std::string> studies;
+    GetAllPublicIds(studies, ResourceType_Study);
+
+    for (std::list<std::string>::const_iterator
+           it = studies.begin(); it != studies.end(); it++)
+    {
+      printf("[%s]\n", it->c_str());
+    }
+
+    transaction->Commit();
+  }
+
+
   void DatabaseWrapper::Upgrade(unsigned int targetVersion,
                                 IStorageArea& storageArea)
   {
-    if (targetVersion != 5)
+    if (targetVersion != 6)
     {
       throw OrthancException(ErrorCode_IncompatibleDatabaseVersion);
     }
 
-    // This version of Orthanc is only compatible with versions 3, 4 and 5 of the DB schema
+    // This version of Orthanc is only compatible with versions 3, 4,
+    // 5 and 6 of the DB schema
     if (version_ != 3 &&
         version_ != 4 &&
-        version_ != 5)
+        version_ != 5 &&
+        version_ != 6)
     {
       throw OrthancException(ErrorCode_IncompatibleDatabaseVersion);
     }
@@ -865,6 +887,13 @@
       ExecuteUpgradeScript(db_, EmbeddedResources::UPGRADE_DATABASE_4_TO_5);
       version_ = 5;
     }
+
+    if (version_ == 5)
+    {
+      LOG(WARNING) << "Upgrading database version from 5 to 6";
+      ExecuteUpgrade5To6(storageArea);
+      version_ = 6;
+    }    
   }