aboutsummaryrefslogtreecommitdiff
path: root/evolution/alter-column/model.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-04-05 10:16:48 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-04-10 18:46:46 +0200
commitf0a8672c2128041001d6badba42ff672126581bb (patch)
treee22750f2dbaf8602c5d14565d93f5a7fa4232704 /evolution/alter-column/model.hxx
parenta72909d40ce4b10d8d5950bec8f52c8a561e4596 (diff)
Generate alter column migration statements
Diffstat (limited to 'evolution/alter-column/model.hxx')
-rw-r--r--evolution/alter-column/model.hxx50
1 files changed, 50 insertions, 0 deletions
diff --git a/evolution/alter-column/model.hxx b/evolution/alter-column/model.hxx
new file mode 100644
index 0000000..c244eb0
--- /dev/null
+++ b/evolution/alter-column/model.hxx
@@ -0,0 +1,50 @@
+// file : evolution/alter-column/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>
+#include <odb/nullable.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)
+{
+ #pragma db object
+ struct object
+ {
+ object (unsigned long id = 0): id_ (id) {}
+
+ #pragma db id
+ unsigned long id_;
+
+#if MODEL_VERSION == 2
+ odb::nullable<std::string> str;
+
+ unsigned long num;
+
+ #pragma db null
+ unsigned long dummy; // Test multiple ALTER COLUMN clauses.
+#else
+ // Use nullable to be able to access during migration.
+ //
+ #pragma db not_null
+ odb::nullable<std::string> str;
+
+ odb::nullable<unsigned long> num;
+
+ unsigned long dummy;
+#endif
+ };
+}
+
+#undef MODEL_NAMESPACE
+#undef MODEL_NAMESPACE_IMPL