diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-01-18 07:35:12 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-01-23 17:47:47 +0200 |
commit | 1dc38cf49b6c7a8b661a9cc675ded94c8ab33c36 (patch) | |
tree | 5a216148adb9d842a5a15c032a671182faa9ba06 /brep/mod-package-search.cxx | |
parent | fe6182a8c89675f92e72c881d707e21cdf56f376 (diff) |
Implement brep-migrate utility
Diffstat (limited to 'brep/mod-package-search.cxx')
-rw-r--r-- | brep/mod-package-search.cxx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/brep/mod-package-search.cxx b/brep/mod-package-search.cxx index 4326435..d649ff4 100644 --- a/brep/mod-package-search.cxx +++ b/brep/mod-package-search.cxx @@ -9,6 +9,7 @@ #include <odb/session.hxx> #include <odb/database.hxx> #include <odb/transaction.hxx> +#include <odb/schema-catalog.hxx> #include <web/xhtml> #include <web/module> @@ -16,6 +17,7 @@ #include <brep/types> #include <brep/utility> +#include <brep/version> #include <brep/page> #include <brep/options> @@ -38,6 +40,20 @@ init (scanner& s) options_->root (dir_path ("/")); db_ = shared_database (*options_); + + // Check that the database schema matches the current one. It's enough to + // perform the check in just a single module implementation (and we don't + // do in the dispatcher because it doesn't use the database). + // + // Note that the failure can be reported by each web server worker process. + // While it could be tempting to move the check to the + // repository_root::version() function, it would be wrong. The function can + // be called by a different process (usually the web server root one) not + // having the proper permissions to access the database. + // + if (schema_catalog::current_version (*db_) != db_->schema_version ()) + fail << "database schema differs from the current one (module " + << BREP_VERSION_STR << ")"; } template <typename T> |