aboutsummaryrefslogtreecommitdiff
path: root/evolution/drop-column/driver.cxx
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/drop-column/driver.cxx
parent7d1e16930e37c4109f439f5ebe1e789b9619a57e (diff)
Add support for embedded schema migration
Diffstat (limited to 'evolution/drop-column/driver.cxx')
-rw-r--r--evolution/drop-column/driver.cxx32
1 files changed, 31 insertions, 1 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)
{