From 51956f409ec7ebea8b6790b0c5d4f0b51513d683 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 15 Sep 2013 12:46:09 +0200 Subject: Cleanup polymorphic base tables when dropping derived one --- odb/relational/oracle/schema.cxx | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'odb/relational/oracle') diff --git a/odb/relational/oracle/schema.cxx b/odb/relational/oracle/schema.cxx index 5856dd2..829a37a 100644 --- a/odb/relational/oracle/schema.cxx +++ b/odb/relational/oracle/schema.cxx @@ -140,13 +140,8 @@ namespace relational drop_table (base const& x): base (x) {} virtual void - traverse (sema_rel::table& t, bool migration) + drop (sema_rel::table& t, bool migration) { - // For Oracle we use the CASCADE clause to drop foreign keys. - // - if (pass_ != 2) - return; - using sema_rel::primary_key; sema_rel::table::names_iterator i (t.find ("")); // Special name. @@ -162,7 +157,7 @@ namespace relational if (migration) { pre_statement (); - os << "DROP TABLE " << qt << " CASCADE CONSTRAINTS" << endl; + os << "DROP TABLE " << qt << endl; post_statement (); // Drop the sequence if we have auto primary key. @@ -207,6 +202,26 @@ namespace relational post_statement (); } } + + virtual void + traverse (sema_rel::table& t, bool migration) + { + // For migration drop foreign keys explicitly in pre-migration. + // + if (migration) + { + base::traverse (t, migration); + return; + } + + // For schema creation we use the CASCADE clause to drop foreign + // keys. + // + if (pass_ != 2) + return; + + drop (t, migration); + } }; entry drop_table_; -- cgit v1.1