diff OrthancServer/DatabaseWrapper.cpp @ 252:bd009f0b1931

db version
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Dec 2012 12:50:25 +0100
parents e4148b0ab1d0
children 2354560daf2f
line wrap: on
line diff
--- a/OrthancServer/DatabaseWrapper.cpp	Wed Dec 05 12:32:43 2012 +0100
+++ b/OrthancServer/DatabaseWrapper.cpp	Wed Dec 05 12:50:25 2012 +0100
@@ -735,6 +735,27 @@
       db_.Execute(query);
     }
 
+    // Sanity check of the version of the database
+    std::string version = GetGlobalProperty(GlobalProperty_DatabaseSchemaVersion, "Unknown");
+    bool ok = false;
+    try
+    {
+      LOG(INFO) << "Version of the Orthanc database: " << version;
+      unsigned int v = boost::lexical_cast<unsigned int>(version);
+
+      // This version of Orthanc is only compatible with version 2 of
+      // the DB schema (since Orthanc 0.3.1)
+      ok = (v == 2); 
+    }
+    catch (boost::bad_lexical_cast&)
+    {
+    }
+
+    if (!ok)
+    {
+      throw OrthancException(ErrorCode_IncompatibleDatabaseVersion);
+    }
+
     signalRemainingAncestor_ = new Internals::SignalRemainingAncestor;
     db_.Register(signalRemainingAncestor_);
     db_.Register(new Internals::SignalFileDeleted(listener_));