aboutsummaryrefslogtreecommitdiff
path: root/evolution/drop-column
diff options
context:
space:
mode:
Diffstat (limited to 'evolution/drop-column')
-rw-r--r--evolution/drop-column/driver.cxx32
-rw-r--r--evolution/drop-column/makefile9
-rw-r--r--evolution/drop-column/model.hxx6
3 files changed, 42 insertions, 5 deletions
diff --git a/evolution/drop-column/driver.cxx b/evolution/drop-column/driver.cxx
index 02d453c..2fddf3a 100644
--- a/evolution/drop-column/driver.cxx
+++ b/evolution/drop-column/driver.cxx
@@ -11,6 +11,7 @@
#include <odb/database.hxx>
#include <odb/transaction.hxx>
+#include <odb/schema-catalog.hxx>
#include <common/common.hxx>
@@ -27,7 +28,12 @@ main (int argc, char* argv[])
{
try
{
- auto_ptr<database> db (create_database (argc, argv));
+ auto_ptr<database> db (create_database (argc, argv, false));
+
+ // SQLite doesn't support dropping of columns.
+ //
+#ifndef DATABASE_SQLITE
+ bool embedded (schema_catalog::exists (*db, "test2"));
// 1 - base version
// 2 - migration
@@ -41,6 +47,15 @@ main (int argc, char* argv[])
{
using namespace v2;
+ if (embedded)
+ {
+ transaction t (db->begin ());
+ schema_catalog::create_schema (*db, "test2");
+ schema_catalog::create_schema (*db, "test1");
+ schema_catalog::migrate_schema (*db, 2, "test2");
+ t.commit ();
+ }
+
object o (1);
o.str = "abc";
o.num = 123;
@@ -56,6 +71,13 @@ main (int argc, char* argv[])
{
using namespace v2; // @@ soft delete
+ if (embedded)
+ {
+ transaction t (db->begin ());
+ schema_catalog::migrate_schema_pre (*db, 3, "test2");
+ t.commit ();
+ }
+
// Things are still there.
//
{
@@ -67,6 +89,13 @@ main (int argc, char* argv[])
t.commit ();
}
+
+ if (embedded)
+ {
+ transaction t (db->begin ());
+ schema_catalog::migrate_schema_post (*db, 3, "test2");
+ t.commit ();
+ }
break;
}
case 3:
@@ -88,6 +117,7 @@ main (int argc, char* argv[])
return 1;
}
}
+#endif // DATABASE_SQLITE
}
catch (const odb::exception& e)
{
diff --git a/evolution/drop-column/makefile b/evolution/drop-column/makefile
index af51386..6bc42fd 100644
--- a/evolution/drop-column/makefile
+++ b/evolution/drop-column/makefile
@@ -29,15 +29,16 @@ $(driver): $(cxx_obj) $(common.l)
$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base)
$(cxx_obj) $(cxx_od): $(common.l.cpp-options)
-genf1 := test1-odb.hxx test1-odb.ixx test1-odb.cxx test1.sql model.xml
+genf1 := test1-odb.hxx test1-odb.ixx test1-odb.cxx model.xml
gen1 := $(addprefix $(out_base)/,$(genf1))
-genf2 := test2-odb.hxx test2-odb.ixx test2-odb.cxx test2.sql \
-test2-002-pre.sql test2-002-post.sql test2-003-pre.sql test2-003-post.sql
+genf2 := test2-odb.hxx test2-odb.ixx test2-odb.cxx
gen2 := $(addprefix $(out_base)/,$(genf2))
genf := $(genf1) $(genf2)
gen := $(gen1) $(gen2)
+gens := test1.sql test2.sql test2-002-pre.sql test2-002-post.sql \
+test2-003-pre.sql test2-003-post.sql
$(gen): $(odb)
$(gen): odb := $(odb)
@@ -113,7 +114,7 @@ $(clean): \
ifeq ($(out_base),$(src_base))
$(driver): | $(out_base)/.gitignore
-$(out_base)/.gitignore: files := driver $(genf)
+$(out_base)/.gitignore: files := driver $(genf) $(gens)
$(clean): $(out_base)/.gitignore.clean
$(call include,$(bld_root)/git/gitignore.make)
diff --git a/evolution/drop-column/model.hxx b/evolution/drop-column/model.hxx
index 0c54252..42a8f54 100644
--- a/evolution/drop-column/model.hxx
+++ b/evolution/drop-column/model.hxx
@@ -11,6 +11,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
@@ -26,10 +28,14 @@ namespace MODEL_NAMESPACE(MODEL_VERSION)
#pragma db id
unsigned long id_;
+ // SQLite doesn't support dropping of columns.
+ //
+#ifndef DATABASE_SQLITE
#if MODEL_VERSION == 2
std::string str;
unsigned long num;
#endif
+#endif
};
}