From b0c2c30dd0b83ea67fb2c8375ae2061dad0d1770 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 9 Apr 2013 16:17:27 +0200 Subject: Add support for embedded schema migration --- evolution/combined/model.hxx | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'evolution/combined/model.hxx') 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 #include +#include // 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 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 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 acn; #endif +#endif // // Pre pass 2. @@ -112,27 +122,33 @@ namespace MODEL_NAMESPACE(MODEL_VERSION) std::vector 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 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 }; } -- cgit v1.1