aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-10-24 08:53:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-10-24 08:53:55 +0200
commit33a8e17efb8c622413a861047c5c4589a9828f62 (patch)
treef726d0ce0ec1ecd007dc0fa6f84378cf2bb82c18
parentec63060967e1c764e80655e8fd3bf40bd3872efd (diff)
Disable SQLite foreign key checking while updating schema2.3.02.3
-rw-r--r--evolution/add-table/driver.cxx10
-rw-r--r--evolution/soft-add/driver.cxx10
-rw-r--r--evolution/soft-delete/driver.cxx11
3 files changed, 30 insertions, 1 deletions
diff --git a/evolution/add-table/driver.cxx b/evolution/add-table/driver.cxx
index bd62068..da4677e 100644
--- a/evolution/add-table/driver.cxx
+++ b/evolution/add-table/driver.cxx
@@ -13,6 +13,7 @@
#include <odb/transaction.hxx>
#include <odb/schema-catalog.hxx>
+#include <common/config.hxx> // DATABASE_XXX
#include <common/common.hxx>
#include "test2.hxx"
@@ -45,11 +46,20 @@ main (int argc, char* argv[])
if (embedded)
{
+ // SQLite has broken foreign keys when it comes to DDL.
+ //
+#ifdef DATABASE_SQLITE
+ db->connection ()->execute ("PRAGMA foreign_keys=OFF");
+#endif
transaction t (db->begin ());
schema_catalog::drop_schema (*db);
schema_catalog::create_schema (*db, "", false);
schema_catalog::migrate_schema (*db, 2);
t.commit ();
+
+#ifdef DATABASE_SQLITE
+ db->connection ()->execute ("PRAGMA foreign_keys=ON");
+#endif
}
object o (1);
diff --git a/evolution/soft-add/driver.cxx b/evolution/soft-add/driver.cxx
index 5ea54d5..699a21a 100644
--- a/evolution/soft-add/driver.cxx
+++ b/evolution/soft-add/driver.cxx
@@ -13,6 +13,7 @@
#include <odb/transaction.hxx>
#include <odb/schema-catalog.hxx>
+#include <common/config.hxx> // DATABASE_XXX
#include <common/common.hxx>
#include "test2.hxx"
@@ -45,11 +46,20 @@ main (int argc, char* argv[])
if (embedded)
{
+ // SQLite has broken foreign keys when it comes to DDL.
+ //
+#ifdef DATABASE_SQLITE
+ db->connection ()->execute ("PRAGMA foreign_keys=OFF");
+#endif
transaction t (db->begin ());
schema_catalog::drop_schema (*db);
schema_catalog::create_schema (*db, "", false);
schema_catalog::migrate_schema (*db, 2);
t.commit ();
+
+#ifdef DATABASE_SQLITE
+ db->connection ()->execute ("PRAGMA foreign_keys=ON");
+#endif
}
// Test basic soft-added member logic.
diff --git a/evolution/soft-delete/driver.cxx b/evolution/soft-delete/driver.cxx
index fa5c810..95b62b5 100644
--- a/evolution/soft-delete/driver.cxx
+++ b/evolution/soft-delete/driver.cxx
@@ -13,8 +13,8 @@
#include <odb/transaction.hxx>
#include <odb/schema-catalog.hxx>
-#include <common/common.hxx>
#include <common/config.hxx> // DATABASE_XXX
+#include <common/common.hxx>
#include "test2.hxx"
#include "test3.hxx"
@@ -46,11 +46,20 @@ main (int argc, char* argv[])
if (embedded)
{
+ // SQLite has broken foreign keys when it comes to DDL.
+ //
+#ifdef DATABASE_SQLITE
+ db->connection ()->execute ("PRAGMA foreign_keys=OFF");
+#endif
transaction t (db->begin ());
schema_catalog::drop_schema (*db);
schema_catalog::create_schema (*db, "", false);
schema_catalog::migrate_schema (*db, 2);
t.commit ();
+
+#ifdef DATABASE_SQLITE
+ db->connection ()->execute ("PRAGMA foreign_keys=ON");
+#endif
}
// Test soft-deleted objects.