Mercurial > hg > orthanc
changeset 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 | eef32b738656 |
children | 761a5c07fb1b |
files | OrthancServer/DatabaseWrapper.cpp OrthancServer/DatabaseWrapper.h |
diffstat | 2 files changed, 34 insertions(+), 3 deletions(-) [+] |
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; + } }
--- 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);