aboutsummaryrefslogtreecommitdiff
path: root/evolution/drop-foreign-key/driver.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'evolution/drop-foreign-key/driver.cxx')
-rw-r--r--evolution/drop-foreign-key/driver.cxx32
1 files changed, 31 insertions, 1 deletions
diff --git a/evolution/drop-foreign-key/driver.cxx b/evolution/drop-foreign-key/driver.cxx
index a63886b..8fe332b 100644
--- a/evolution/drop-foreign-key/driver.cxx
+++ b/evolution/drop-foreign-key/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 foreign keys.
+ //
+#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.o1 = new object (2);
o.o2 = new object (3);
@@ -72,6 +87,13 @@ main (int argc, char* argv[])
{
using namespace v3;
+ if (embedded)
+ {
+ transaction t (db->begin ());
+ schema_catalog::migrate_schema_pre (*db, 3, "test2");
+ t.commit ();
+ }
+
// The data is still there but the constraints are gone.
//
{
@@ -86,6 +108,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:
@@ -107,6 +136,7 @@ main (int argc, char* argv[])
return 1;
}
}
+#endif // DATABASE_SQLITE
}
catch (const odb::exception& e)
{