aboutsummaryrefslogtreecommitdiff
path: root/evolution/add-foreign-key/model.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-04-08 11:13:52 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-04-10 18:46:47 +0200
commitacd66db1ce8aa960b34710857ce990dd048cd3ae (patch)
tree05a355b8b2c0a9c40a54ab20d529188ee36ec34a /evolution/add-foreign-key/model.hxx
parent0429c7b008594a874696f91c29b17ae4ee40efff (diff)
Generate add/drop foreign key migration statements
Also add the --fkeys-deferrable-mode option. General schemas generation rework.
Diffstat (limited to 'evolution/add-foreign-key/model.hxx')
-rw-r--r--evolution/add-foreign-key/model.hxx61
1 files changed, 61 insertions, 0 deletions
diff --git a/evolution/add-foreign-key/model.hxx b/evolution/add-foreign-key/model.hxx
new file mode 100644
index 0000000..e73e47a
--- /dev/null
+++ b/evolution/add-foreign-key/model.hxx
@@ -0,0 +1,61 @@
+// file : evolution/add-foreign-key/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 <string>
+
+#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 object1
+ {
+ object1 (unsigned long id = 0): id_ (id) {}
+
+ #pragma db id
+ unsigned long id_;
+ };
+
+ #pragma db object
+ struct object2
+ {
+ object2 (unsigned long id = 0): id_ (id) {}
+
+ #pragma db id
+ unsigned long id_;
+ };
+#endif
+
+ #pragma db object
+ struct object
+ {
+ #pragma db id
+ unsigned long id_;
+
+#if MODEL_VERSION == 2
+ object (unsigned long id = 0): id_ (id) {}
+#else
+ object1* o1;
+
+ #pragma db not_null
+ object2* o2;
+
+ object (unsigned long id = 0): id_ (id), o1 (0), o2 (0) {}
+ ~object () {delete o1; delete o2;}
+#endif
+ };
+}
+
+#undef MODEL_NAMESPACE
+#undef MODEL_NAMESPACE_IMPL