aboutsummaryrefslogtreecommitdiff
path: root/evolution/template/model.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-04-03 11:22:42 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-04-10 18:46:46 +0200
commit516523183fad016a26c7400d784eb9c0343b7964 (patch)
treeb2e5df0194c28df2b9bcaf822f6f06b92a267118 /evolution/template/model.hxx
parente7f6315882ef16939f99dd757eaf800b9f12e92b (diff)
Generate add/drop table migration statements
Diffstat (limited to 'evolution/template/model.hxx')
-rw-r--r--evolution/template/model.hxx41
1 files changed, 41 insertions, 0 deletions
diff --git a/evolution/template/model.hxx b/evolution/template/model.hxx
new file mode 100644
index 0000000..ef6c9d0
--- /dev/null
+++ b/evolution/template/model.hxx
@@ -0,0 +1,41 @@
+// file : evolution/template/model.hxx
+// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef MODEL_VERSION
+# error model.hxx included directly
+#endif
+
+#include <odb/core.hxx>
+
+#pragma db model version(1, MODEL_VERSION)
+
+#define MODEL_NAMESPACE_IMPL(V) v##V
+#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V)
+
+namespace MODEL_NAMESPACE(MODEL_VERSION)
+{
+#if MODEL_VERSION == 3
+ #pragma db object
+ struct object
+ {
+ #pragma db id auto
+ unsigned long id_;
+ };
+#endif
+
+ // The presence of this object makes sure that there are no empty
+ // changesets and we get the complete set of migration files.
+ //
+ #pragma db object
+ struct dummy
+ {
+ dummy (unsigned long id = 0): id_ (id) {}
+
+ #pragma db id
+ unsigned long id_;
+ };
+}
+
+#undef MODEL_NAMESPACE
+#undef MODEL_NAMESPACE_IMPL