# HG changeset patch # User Sebastien Jodogne # Date 1443613400 -7200 # Node ID 0c58f189782da2cbd9428b8428fe36a3443c3c27 # Parent eef32b7386560cbb2282daee8b9ae110e2455b2a prepare migration to db v6 diff -r eef32b738656 -r 0c58f189782d OrthancServer/DatabaseWrapper.cpp --- 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 transaction(StartTransaction()); + transaction->Begin(); + + std::list studies; + GetAllPublicIds(studies, ResourceType_Study); + + for (std::list::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; + } } diff -r eef32b738656 -r 0c58f189782d OrthancServer/DatabaseWrapper.h --- a/OrthancServer/DatabaseWrapper.h Wed Sep 30 13:36:30 2015 +0200 +++ b/OrthancServer/DatabaseWrapper.h Wed Sep 30 13:43:20 2015 +0200 @@ -71,6 +71,8 @@ void ClearTable(const std::string& tableName); + void ExecuteUpgrade5To6(IStorageArea& storageArea); + public: DatabaseWrapper(const std::string& path);