Mercurial > hg > orthanc
comparison OrthancServer/DatabaseWrapper.cpp @ 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 | c40fe92a68e7 |
children | 761a5c07fb1b |
comparison
equal
deleted
inserted
replaced
1663:eef32b738656 | 1664:0c58f189782d |
---|---|
834 db.Execute(upgrade); | 834 db.Execute(upgrade); |
835 db.CommitTransaction(); | 835 db.CommitTransaction(); |
836 } | 836 } |
837 | 837 |
838 | 838 |
839 void DatabaseWrapper::ExecuteUpgrade5To6(IStorageArea& storageArea) | |
840 { | |
841 printf("ICI\n"); | |
842 | |
843 std::auto_ptr<SQLite::ITransaction> transaction(StartTransaction()); | |
844 transaction->Begin(); | |
845 | |
846 std::list<std::string> studies; | |
847 GetAllPublicIds(studies, ResourceType_Study); | |
848 | |
849 for (std::list<std::string>::const_iterator | |
850 it = studies.begin(); it != studies.end(); it++) | |
851 { | |
852 printf("[%s]\n", it->c_str()); | |
853 } | |
854 | |
855 transaction->Commit(); | |
856 } | |
857 | |
858 | |
839 void DatabaseWrapper::Upgrade(unsigned int targetVersion, | 859 void DatabaseWrapper::Upgrade(unsigned int targetVersion, |
840 IStorageArea& storageArea) | 860 IStorageArea& storageArea) |
841 { | 861 { |
842 if (targetVersion != 5) | 862 if (targetVersion != 6) |
843 { | 863 { |
844 throw OrthancException(ErrorCode_IncompatibleDatabaseVersion); | 864 throw OrthancException(ErrorCode_IncompatibleDatabaseVersion); |
845 } | 865 } |
846 | 866 |
847 // This version of Orthanc is only compatible with versions 3, 4 and 5 of the DB schema | 867 // This version of Orthanc is only compatible with versions 3, 4, |
868 // 5 and 6 of the DB schema | |
848 if (version_ != 3 && | 869 if (version_ != 3 && |
849 version_ != 4 && | 870 version_ != 4 && |
850 version_ != 5) | 871 version_ != 5 && |
872 version_ != 6) | |
851 { | 873 { |
852 throw OrthancException(ErrorCode_IncompatibleDatabaseVersion); | 874 throw OrthancException(ErrorCode_IncompatibleDatabaseVersion); |
853 } | 875 } |
854 | 876 |
855 if (version_ == 3) | 877 if (version_ == 3) |
863 { | 885 { |
864 LOG(WARNING) << "Upgrading database version from 4 to 5"; | 886 LOG(WARNING) << "Upgrading database version from 4 to 5"; |
865 ExecuteUpgradeScript(db_, EmbeddedResources::UPGRADE_DATABASE_4_TO_5); | 887 ExecuteUpgradeScript(db_, EmbeddedResources::UPGRADE_DATABASE_4_TO_5); |
866 version_ = 5; | 888 version_ = 5; |
867 } | 889 } |
890 | |
891 if (version_ == 5) | |
892 { | |
893 LOG(WARNING) << "Upgrading database version from 5 to 6"; | |
894 ExecuteUpgrade5To6(storageArea); | |
895 version_ = 6; | |
896 } | |
868 } | 897 } |
869 | 898 |
870 | 899 |
871 void DatabaseWrapper::SetListener(IDatabaseListener& listener) | 900 void DatabaseWrapper::SetListener(IDatabaseListener& listener) |
872 { | 901 { |