aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/circular/multiple/driver.cxx22
1 files changed, 21 insertions, 1 deletions
diff --git a/common/circular/multiple/driver.cxx b/common/circular/multiple/driver.cxx
index 2f28911..1b80218 100644
--- a/common/circular/multiple/driver.cxx
+++ b/common/circular/multiple/driver.cxx
@@ -11,9 +11,11 @@
#include <iostream>
#include <odb/database.hxx>
+#include <odb/connection.hxx>
#include <odb/transaction.hxx>
#include <odb/schema-catalog.hxx>
+#include <common/config.hxx> // DATABASE_XXX
#include <common/common.hxx>
#include "test1.hxx"
@@ -35,9 +37,27 @@ main (int argc, char* argv[])
// Create the database schema.
//
{
- transaction t (db->begin ());
+ connection_ptr c (db->connection ());
+
+ // Temporarily disable foreign key constraints for MySQL and SQLite.
+ // For these databases this is the only way to drop circularly-
+ // dependant tables.
+ //
+#if defined(DATABASE_MYSQL)
+ c->execute ("SET FOREIGN_KEY_CHECKS=0");
+#elif defined(DATABASE_SQLITE)
+ c->execute ("PRAGMA foreign_keys=OFF");
+#endif
+
+ transaction t (c->begin ());
schema_catalog::create_schema (*db);
t.commit ();
+
+#if defined(DATABASE_MYSQL)
+ c->execute ("SET FOREIGN_KEY_CHECKS=1");
+#elif defined(DATABASE_SQLITE)
+ c->execute ("PRAGMA foreign_keys=ON");
+#endif
}
query<base> bq (query<base>::d->id != 0);