Mercurial > hg > orthanc
comparison OrthancServer/DatabaseWrapper.cpp @ 694:72dc919a028c
upgrade database from v3 to v4
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 05 Feb 2014 13:26:19 +0100 |
parents | 01d8611c4a60 |
children | 2929e17f8447 |
comparison
equal
deleted
inserted
replaced
693:01d8611c4a60 | 694:72dc919a028c |
---|---|
65 return 7; | 65 return 7; |
66 } | 66 } |
67 | 67 |
68 virtual void Compute(SQLite::FunctionContext& context) | 68 virtual void Compute(SQLite::FunctionContext& context) |
69 { | 69 { |
70 std::string uncompressedMD5, compressedMD5; | |
71 | |
72 if (!context.IsNullValue(5)) | |
73 { | |
74 uncompressedMD5 = context.GetStringValue(5); | |
75 } | |
76 | |
77 if (!context.IsNullValue(6)) | |
78 { | |
79 compressedMD5 = context.GetStringValue(6); | |
80 } | |
81 | |
70 FileInfo info(context.GetStringValue(0), | 82 FileInfo info(context.GetStringValue(0), |
71 static_cast<FileContentType>(context.GetIntValue(1)), | 83 static_cast<FileContentType>(context.GetIntValue(1)), |
72 static_cast<uint64_t>(context.GetInt64Value(2)), | 84 static_cast<uint64_t>(context.GetInt64Value(2)), |
73 context.GetStringValue(5), | 85 uncompressedMD5, |
74 static_cast<CompressionType>(context.GetIntValue(3)), | 86 static_cast<CompressionType>(context.GetIntValue(3)), |
75 static_cast<uint64_t>(context.GetInt64Value(4)), | 87 static_cast<uint64_t>(context.GetInt64Value(4)), |
76 context.GetStringValue(6)); | 88 compressedMD5); |
77 | 89 |
78 listener_.SignalFileDeleted(info); | 90 listener_.SignalFileDeleted(info); |
79 } | 91 } |
80 }; | 92 }; |
81 | 93 |
824 try | 836 try |
825 { | 837 { |
826 LOG(INFO) << "Version of the Orthanc database: " << version; | 838 LOG(INFO) << "Version of the Orthanc database: " << version; |
827 unsigned int v = boost::lexical_cast<unsigned int>(version); | 839 unsigned int v = boost::lexical_cast<unsigned int>(version); |
828 | 840 |
829 // Version 3: from Orthanc 0.3.2 to Orthanc 0.7.2 (inclusive) | 841 /** |
830 // Version 4: from Orthanc 0.7.3 (inclusive) | 842 * History of the database versions: |
831 | 843 * - Version 3: from Orthanc 0.3.2 to Orthanc 0.7.2 (inclusive) |
832 // This version of Orthanc is only compatible with version 4 of the DB schema | 844 * - Version 4: from Orthanc 0.7.3 (inclusive) |
833 ok = (v == 4); | 845 **/ |
846 | |
847 // This version of Orthanc is only compatible with versions 3 of 4 of the DB schema | |
848 ok = (v == 3 || v == 4); | |
849 | |
850 if (v == 3) | |
851 { | |
852 LOG(WARNING) << "Upgrading database version from 3 to 4"; | |
853 std::string upgrade; | |
854 EmbeddedResources::GetFileResource(upgrade, EmbeddedResources::UPGRADE_DATABASE_3_TO_4); | |
855 db_.BeginTransaction(); | |
856 db_.Execute(upgrade); | |
857 db_.CommitTransaction(); | |
858 } | |
834 } | 859 } |
835 catch (boost::bad_lexical_cast&) | 860 catch (boost::bad_lexical_cast&) |
836 { | 861 { |
837 } | 862 } |
838 | 863 |