Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPluginDatabase.cpp @ 1615:c40fe92a68e7
Primitives to upgrade the database version in plugins
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 16 Sep 2015 15:18:59 +0200 |
parents | c74495267acf |
children | 0a2ad4a6858f |
comparison
equal
deleted
inserted
replaced
1614:1c9e99d2bfd2 | 1615:c40fe92a68e7 |
---|---|
980 throw OrthancException(ErrorCode_Plugin); | 980 throw OrthancException(ErrorCode_Plugin); |
981 } | 981 } |
982 } | 982 } |
983 | 983 |
984 | 984 |
985 unsigned int OrthancPluginDatabase::GetDatabaseVersion() | |
986 { | |
987 if (extensions_.getDatabaseVersion != NULL) | |
988 { | |
989 uint32_t version; | |
990 if (extensions_.getDatabaseVersion(&version, payload_) != 0) | |
991 { | |
992 throw OrthancException(ErrorCode_Plugin); | |
993 } | |
994 | |
995 return version; | |
996 } | |
997 else | |
998 { | |
999 // Before adding the "GetDatabaseVersion()" extension in plugins | |
1000 // (OrthancPostgreSQL <= 1.2), the only supported DB schema was | |
1001 // version 5. | |
1002 return 5; | |
1003 } | |
1004 } | |
1005 | |
1006 | |
1007 void OrthancPluginDatabase::Upgrade(unsigned int targetVersion, | |
1008 IStorageArea& storageArea) | |
1009 { | |
1010 if (extensions_.upgradeDatabase != NULL) | |
1011 { | |
1012 if (extensions_.upgradeDatabase( | |
1013 payload_, targetVersion, | |
1014 reinterpret_cast<OrthancPluginStorageArea*>(&storageArea)) != 0) | |
1015 { | |
1016 throw OrthancException(ErrorCode_Plugin); | |
1017 } | |
1018 } | |
1019 } | |
1020 | |
1021 | |
985 void OrthancPluginDatabase::AnswerReceived(const _OrthancPluginDatabaseAnswer& answer) | 1022 void OrthancPluginDatabase::AnswerReceived(const _OrthancPluginDatabaseAnswer& answer) |
986 { | 1023 { |
987 if (answer.type == _OrthancPluginDatabaseAnswerType_None) | 1024 if (answer.type == _OrthancPluginDatabaseAnswerType_None) |
988 { | 1025 { |
989 throw OrthancException(ErrorCode_Plugin); | 1026 throw OrthancException(ErrorCode_Plugin); |