aboutsummaryrefslogtreecommitdiff
path: root/evolution/combined/model.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-04-09 16:17:27 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-04-10 18:46:47 +0200
commitb0c2c30dd0b83ea67fb2c8375ae2061dad0d1770 (patch)
treeb1fbada48dab47c2477c6016a45cfac957670346 /evolution/combined/model.hxx
parent7d1e16930e37c4109f439f5ebe1e789b9619a57e (diff)
Add support for embedded schema migration
Diffstat (limited to 'evolution/combined/model.hxx')
-rw-r--r--evolution/combined/model.hxx33
1 files changed, 27 insertions, 6 deletions
diff --git a/evolution/combined/model.hxx b/evolution/combined/model.hxx
index 2aede90..2cdc9d7 100644
--- a/evolution/combined/model.hxx
+++ b/evolution/combined/model.hxx
@@ -12,6 +12,8 @@
#include <odb/core.hxx>
#include <odb/nullable.hxx>
+#include <common/config.hxx> // DATABASE_XXX
+
#pragma db model version(1, MODEL_VERSION)
#define MODEL_NAMESPACE_IMPL(V) v##V
@@ -45,14 +47,16 @@ namespace MODEL_NAMESPACE(MODEL_VERSION)
#endif
unsigned long dui;
- // Alter table drop foreign key.
+ // Alter table drop foreign key. Not supported by SQLite.
//
+#ifndef DATABASE_SQLITE
#if MODEL_VERSION == 2
object1* dfk;
#else
#pragma db null
unsigned long dfk;
#endif
+#endif
// Add table.
//
@@ -68,17 +72,23 @@ namespace MODEL_NAMESPACE(MODEL_VERSION)
odb::nullable<unsigned long> ac2;
- #pragma db not_null // Initially added as NULL, converted to NOT NULL.
+ // Initially added as NULL, converted to NOT NULL. Not supported by SQLite.
+ //
+#ifndef DATABASE_SQLITE
+ #pragma db not_null
odb::nullable<unsigned long> ac3;
#endif
+#endif
- // Alter column NULL.
+ // Alter column NULL. Not supported by SQLite.
//
+#ifndef DATABASE_SQLITE
#if MODEL_VERSION == 2
unsigned long acn;
#else
odb::nullable<unsigned long> acn;
#endif
+#endif
//
// Pre pass 2.
@@ -112,27 +122,33 @@ namespace MODEL_NAMESPACE(MODEL_VERSION)
std::vector<unsigned long> dt;
#endif
- // Drop column.
+ // Drop column. Not supported by SQLite.
//
+#ifndef DATABASE_SQLITE
#if MODEL_VERSION == 2
unsigned long dc;
#endif
+#endif
- // Alter column NOT NULL.
+ // Alter column NOT NULL. Not supported by SQLite.
//
+#ifndef DATABASE_SQLITE
#if MODEL_VERSION == 3
#pragma db not_null
#endif
odb::nullable<unsigned long> acnn;
+#endif
- // Alter table add foreign key.
+ // Alter table add foreign key. Not supported by SQLite.
//
+#ifndef DATABASE_SQLITE
#if MODEL_VERSION == 2
#pragma db null
unsigned long afk;
#else
object1* afk;
#endif
+#endif
// Add unique index.
//
@@ -142,13 +158,18 @@ namespace MODEL_NAMESPACE(MODEL_VERSION)
unsigned long aui;
public:
+#ifndef DATABASE_SQLITE
#if MODEL_VERSION == 2
+
object (std::string id = ""): id_ (id), dfk (0) {}
~object () {delete dfk;}
#else
object (std::string id = ""): id_ (id), afk (0) {}
~object () {delete afk;}
#endif
+#else
+ object (std::string id = ""): id_ (id) {}
+#endif
};
}