diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-21 10:47:30 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-21 10:47:30 +0200 |
commit | 6a6095112daabd18d445ecf0d4c05e993e54236c (patch) | |
tree | 215997450ae13f63b0102d90daf41e104d1b0fc9 /odb/relational/source.hxx | |
parent | a26f4251e67ccaaaa848982946c8867443092ebe (diff) |
Add support for multi-pass database schema drop
Diffstat (limited to 'odb/relational/source.hxx')
-rw-r--r-- | odb/relational/source.hxx | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/odb/relational/source.hxx b/odb/relational/source.hxx index d30f605..9289206 100644 --- a/odb/relational/source.hxx +++ b/odb/relational/source.hxx @@ -2611,11 +2611,11 @@ namespace relational new_pass_ = false; empty_ = false; - if (pass_ == 0) + if (pass_ == 1) { os << "switch (pass)" << "{" - << "case 0:" << endl + << "case 1:" << endl << "{"; } else @@ -2658,34 +2658,59 @@ namespace relational // create_schema () // os << "bool " << traits << "::" << endl - << "create_schema (database& db, unsigned short pass)" + << "create_schema (database& db, unsigned short pass, bool drop)" << "{" << "ODB_POTENTIALLY_UNUSED (db);" << "ODB_POTENTIALLY_UNUSED (pass);" << endl; - bool close (false); - - // Pass 0. + // Drop. // - schema_emitter_.pass (0); - schema_drop_->traverse (c); - close = close || !schema_emitter_.empty (); + { + bool close (false); + + os << "if (drop)" + << "{"; + + for (unsigned short pass (1); pass < 3; ++pass) + { + schema_emitter_.pass (pass); + schema_drop_->pass (pass); + schema_drop_->traverse (c); + close = close || !schema_emitter_.empty (); + } + + if (close) // Close the last case and the switch block. + os << "return false;" + << "}" // case + << "}"; // switch + + os << "}"; + } - // Pass 1 and 2. + // Create. // - for (unsigned short pass (1); pass < 3; ++pass) { - schema_emitter_.pass (pass); - schema_create_->pass (pass); - schema_create_->traverse (c); - close = close || !schema_emitter_.empty (); - } + bool close (false); + + os << "else" + << "{"; + + for (unsigned short pass (1); pass < 3; ++pass) + { + schema_emitter_.pass (pass); + schema_create_->pass (pass); + schema_create_->traverse (c); + close = close || !schema_emitter_.empty (); + } + + if (close) // Close the last case and the switch block. + os << "return false;" + << "}" // case + << "}"; // switch - if (close) // Close the last case and the switch block. - os << "return false;" - << "}" // case - << "}"; // switch + os << "}"; + } os << "return false;" << "}"; |