aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-08-28 07:52:50 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-08-28 07:52:50 +0200
commit08022a07eead928949be5581f1202a197bf68551 (patch)
tree657fb45ee2b1510d157b8146a0bd02684a12e3c2
parent74f50a3bc6890c96532fe9e76e387171aec3a8c3 (diff)
Support for added and deleted data member pragmas
-rw-r--r--odb/database.hxx11
-rw-r--r--odb/database.ixx13
-rw-r--r--odb/forward.hxx11
-rw-r--r--odb/schema-catalog.cxx2
-rw-r--r--odb/schema-version.hxx73
5 files changed, 96 insertions, 14 deletions
diff --git a/odb/database.hxx b/odb/database.hxx
index a4ef058..ea5a37a 100644
--- a/odb/database.hxx
+++ b/odb/database.hxx
@@ -20,6 +20,7 @@
#include <odb/traits.hxx>
#include <odb/forward.hxx>
+#include <odb/schema-version.hxx>
#include <odb/query.hxx>
#include <odb/prepared-query.hxx>
#include <odb/result.hxx>
@@ -349,9 +350,13 @@ namespace odb
// Set schema version and migration state manually.
//
void
- schema_version (schema_version_type,
- bool migration,
- const std::string& schema_name = "");
+ schema_version_migration (schema_version_type,
+ bool migration,
+ const std::string& schema_name = "");
+
+ void
+ schema_version_migration (const schema_version_migration_type&,
+ const std::string& schema_name = "");
// Set default schema version table for all schema names. The table
// name should already be quoted if necessary.
diff --git a/odb/database.ixx b/odb/database.ixx
index 817aebe..2fa57b3 100644
--- a/odb/database.ixx
+++ b/odb/database.ixx
@@ -43,7 +43,9 @@ namespace odb
}
inline void database::
- schema_version (schema_version_type v, bool m, const std::string& name)
+ schema_version_migration (schema_version_type v,
+ bool m,
+ const std::string& name)
{
schema_version_info& svi (schema_version_map_[name]);
svi.version = v;
@@ -51,6 +53,15 @@ namespace odb
}
inline void database::
+ schema_version_migration (const schema_version_migration_type& svm,
+ const std::string& name)
+ {
+ schema_version_info& svi (schema_version_map_[name]);
+ svi.version = svm.version;
+ svi.migration = svm.migration;
+ }
+
+ inline void database::
schema_version_table (const std::string& tname)
{
schema_version_table_ = tname;
diff --git a/odb/forward.hxx b/odb/forward.hxx
index 7a4cd98..c727215 100644
--- a/odb/forward.hxx
+++ b/odb/forward.hxx
@@ -28,15 +28,7 @@ namespace odb
//
//
typedef unsigned long long schema_version;
-
- struct schema_version_migration
- {
- schema_version_migration (schema_version v = 0, bool m = false)
- : version (v), migration (m) {}
-
- schema_version version;
- bool migration;
- };
+ struct schema_version_migration;
class database;
class connection;
@@ -49,6 +41,7 @@ namespace odb
namespace common
{
using odb::schema_version;
+ using odb::schema_version_migration;
using odb::session;
using odb::section;
}
diff --git a/odb/schema-catalog.cxx b/odb/schema-catalog.cxx
index fefb52c..8a5ce71 100644
--- a/odb/schema-catalog.cxx
+++ b/odb/schema-catalog.cxx
@@ -191,7 +191,7 @@ namespace odb
// Update the schema version on the database instance.
//
- db.schema_version (v, m == migrate_pre, name);
+ db.schema_version_migration (v, m == migrate_pre, name);
}
void schema_catalog::
diff --git a/odb/schema-version.hxx b/odb/schema-version.hxx
new file mode 100644
index 0000000..fc7ec0d
--- /dev/null
+++ b/odb/schema-version.hxx
@@ -0,0 +1,73 @@
+// file : odb/schema-version.hxx
+// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_SCHEMA_VERSION_HXX
+#define ODB_SCHEMA_VERSION_HXX
+
+#include <odb/pre.hxx>
+
+#include <odb/forward.hxx> // schema_version
+#include <odb/details/export.hxx>
+
+namespace odb
+{
+ struct LIBODB_EXPORT schema_version_migration
+ {
+ schema_version_migration (schema_version v = 0, bool m = false)
+ : version (v), migration (m) {}
+
+ schema_version version;
+ bool migration;
+ };
+
+ // Version ordering is as follows: {1,f} < {2,t} < {2,f} < {3,t}
+ //
+ inline bool
+ operator== (const schema_version_migration& x,
+ const schema_version_migration& y)
+ {
+ return x.version == y.version && x.migration == y.migration;
+ }
+
+ inline bool
+ operator!= (const schema_version_migration& x,
+ const schema_version_migration& y)
+ {
+ return !(x == y);
+ }
+
+ inline bool
+ operator< (const schema_version_migration& x,
+ const schema_version_migration& y)
+ {
+ return x.version < y.version ||
+ (x.version == y.version && x.migration && !y.migration);
+ }
+
+ inline bool
+ operator> (const schema_version_migration& x,
+ const schema_version_migration& y)
+ {
+ return x.version > y.version ||
+ (x.version == y.version && !x.migration && y.migration);
+ }
+
+ inline bool
+ operator<= (const schema_version_migration& x,
+ const schema_version_migration& y)
+ {
+ return !(x > y);
+ }
+
+ inline bool
+ operator>= (const schema_version_migration& x,
+ const schema_version_migration& y)
+ {
+ return !(x < y);
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_SCHEMA_VERSION_HXX