diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-10-05 11:21:32 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-10-05 11:21:32 +0200 |
commit | 6fce0f81df649b1d9086fe089304372858ce38ee (patch) | |
tree | ae85f2a9756df94dc4ea2629574d8f0f3dbcdd67 | |
parent | 17848e4cb98f88806e13a2b6f98a38e36a5d63e0 (diff) |
Add schema_catalog::base_version() for completeness
-rw-r--r-- | odb/schema-catalog.cxx | 14 | ||||
-rw-r--r-- | odb/schema-catalog.hxx | 11 |
2 files changed, 25 insertions, 0 deletions
diff --git a/odb/schema-catalog.cxx b/odb/schema-catalog.cxx index bec13a7..7205ff6 100644 --- a/odb/schema-catalog.cxx +++ b/odb/schema-catalog.cxx @@ -283,6 +283,20 @@ namespace odb } schema_version schema_catalog:: + base_version (database_id id, const string& name) + { + const schema_catalog_impl& c (*schema_catalog_init::catalog); + schema_map::const_iterator i (c.schema.find (key (id, name))); + + if (i == c.schema.end ()) + throw unknown_schema (name); + + const version_map& vm (i->second.migrate); + assert (!vm.empty ()); + return vm.begin ()->first; + } + + schema_version schema_catalog:: current_version (database_id id, const string& name) { const schema_catalog_impl& c (*schema_catalog_init::catalog); diff --git a/odb/schema-catalog.hxx b/odb/schema-catalog.hxx index 953f099..8b06a79 100644 --- a/odb/schema-catalog.hxx +++ b/odb/schema-catalog.hxx @@ -168,6 +168,17 @@ namespace odb // Schema version information. // public: + // Return the base model version. + // + static schema_version + base_version (const database& db, const std::string& name = "") + { + return base_version (db.id (), name); + } + + static schema_version + base_version (database_id, const std::string& name = ""); + // Return the current model version. // static schema_version |