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/drop-table/driver.cxx | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'evolution/drop-table/driver.cxx') diff --git a/evolution/drop-table/driver.cxx b/evolution/drop-table/driver.cxx index 2a48ed5..6ab29f0 100644 --- a/evolution/drop-table/driver.cxx +++ b/evolution/drop-table/driver.cxx @@ -11,6 +11,7 @@ #include #include +#include #include @@ -27,7 +28,8 @@ main (int argc, char* argv[]) { try { - auto_ptr db (create_database (argc, argv)); + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db, "test2")); // 1 - base version // 2 - migration @@ -41,6 +43,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 (); + } + object1 o1; o1.o = new object (1); o1.o->str = "abc"; @@ -60,6 +71,13 @@ main (int argc, char* argv[]) { using namespace v2; // @@ v3; soft immediate drop + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3, "test2"); + t.commit (); + } + // Both object and object1 are still there so we can migrate the data. // typedef odb::query query; @@ -79,6 +97,12 @@ main (int argc, char* argv[]) t.commit (); } + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3, "test2"); + t.commit (); + } break; } case 3: -- cgit v1.1