comparison OrthancServer/DatabaseWrapper.cpp @ 1407:d371a66972a4

OrthancPluginGetExpectedDatabaseVersion
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 Jun 2015 10:19:13 +0200
parents 5fe254fb1c93
children 0ac74fa21db8
comparison
equal deleted inserted replaced
1406:d29e56f59dcf 1407:d371a66972a4
794 try 794 try
795 { 795 {
796 LOG(INFO) << "Version of the Orthanc database: " << version; 796 LOG(INFO) << "Version of the Orthanc database: " << version;
797 unsigned int v = boost::lexical_cast<unsigned int>(version); 797 unsigned int v = boost::lexical_cast<unsigned int>(version);
798 798
799 /**
800 * History of the database versions:
801 * - Orthanc before Orthanc 0.3.0 (inclusive) had no version
802 * - Version 2: only Orthanc 0.3.1
803 * - Version 3: from Orthanc 0.3.2 to Orthanc 0.7.2 (inclusive)
804 * - Version 4: from Orthanc 0.7.3 to Orthanc 0.8.4 (inclusive)
805 * - Version 5: from Orthanc 0.8.5 (inclusive)
806 **/
807
808 // This version of Orthanc is only compatible with versions 3, 4 and 5 of the DB schema 799 // This version of Orthanc is only compatible with versions 3, 4 and 5 of the DB schema
809 ok = (v == 3 || v == 4 || v == 5); 800 ok = (v == 3 || v == 4 || v == 5);
810 801
811 if (v == 3) 802 if (v == 3)
812 { 803 {
818 if (v == 4) 809 if (v == 4)
819 { 810 {
820 LOG(WARNING) << "Upgrading database version from 4 to 5"; 811 LOG(WARNING) << "Upgrading database version from 4 to 5";
821 UpgradeDatabase(db_, EmbeddedResources::UPGRADE_DATABASE_4_TO_5); 812 UpgradeDatabase(db_, EmbeddedResources::UPGRADE_DATABASE_4_TO_5);
822 v = 5; 813 v = 5;
814 }
815
816 // Sanity check
817 if (ORTHANC_DATABASE_VERSION != v)
818 {
819 throw OrthancException(ErrorCode_InternalError);
823 } 820 }
824 } 821 }
825 catch (boost::bad_lexical_cast&) 822 catch (boost::bad_lexical_cast&)
826 { 823 {
827 ok = false; 824 ok = false;