From d78ba3e97cbe0d6c641120d94d47e25b198febfb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 25 Apr 2013 07:35:45 +0200 Subject: Add support for schema version table --- odb/database.hxx | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'odb/database.hxx') diff --git a/odb/database.hxx b/odb/database.hxx index 6876850..79fa622 100644 --- a/odb/database.hxx +++ b/odb/database.hxx @@ -317,6 +317,47 @@ namespace odb tracer_type* tracer () const; + // Database schema version. + // + public: + typedef odb::schema_version schema_version_type; + + schema_version_type + schema_version (const std::string& schema_name = "") const; + + bool + schema_migration (const std::string& schema_name = "") const; + + // Set schema version and migration state manually. + // + void + schema_version (schema_version_type, + bool migration, + const std::string& schema_name = ""); + + // Set default schema version table for all schema names. The table + // name should already be quoted if necessary. + // + void + schema_version_table (const std::string& table_name); + + // Set schema version table for a specific schema. + // + void + schema_version_table (const std::string& table_name, + const std::string& schema_name); + + protected: + struct schema_version_info + { + schema_version_type version; + bool migration; + std::string version_table; + }; + + virtual const schema_version_info& + load_schema_version (const std::string& schema_name) const = 0; + // Database id. // public: @@ -393,9 +434,14 @@ namespace odb std::map query_factory_map; + typedef std::map schema_version_map; + database_id id_; tracer_type* tracer_; query_factory_map query_factory_map_; + + std::string schema_version_table_; + mutable schema_version_map schema_version_map_; }; } -- cgit v1.1