From e32e4b9d8d79dd5491891b1a2c5ac9ad9b631780 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 17 Sep 2013 12:01:47 +0200 Subject: Add schema name to changelog --- odb/generator.cxx | 9 +++++++++ odb/relational/changelog.cxx | 3 ++- odb/semantics/relational/changelog.cxx | 3 +++ odb/semantics/relational/changelog.hxx | 7 ++++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/odb/generator.cxx b/odb/generator.cxx index 6bdd594..6971059 100644 --- a/odb/generator.cxx +++ b/odb/generator.cxx @@ -261,6 +261,15 @@ generate (options const& ops, "'" << endl; throw generator::failed (); } + + string sn (ops.schema_name ()[db]); + if (old_changelog->schema_name () != sn) + { + cerr << in_log_path << ": error: wrong schema name '" << + old_changelog->schema_name () << "', expected '" << sn << + "'" << endl; + throw generator::failed (); + } } catch (const ios_base::failure& e) { diff --git a/odb/relational/changelog.cxx b/odb/relational/changelog.cxx index ca796a9..855ba65 100644 --- a/odb/relational/changelog.cxx +++ b/odb/relational/changelog.cxx @@ -1023,8 +1023,9 @@ namespace relational string const& out_name, options const& ops) { + database db (ops.database ()[0]); cutl::shared_ptr cl ( - new (shared) changelog (ops.database ()[0].string ())); + new (shared) changelog (db.string (), ops.schema_name ()[db])); graph& g (*cl); if (old == 0) diff --git a/odb/semantics/relational/changelog.cxx b/odb/semantics/relational/changelog.cxx index 73dac77..800fb97 100644 --- a/odb/semantics/relational/changelog.cxx +++ b/odb/semantics/relational/changelog.cxx @@ -30,6 +30,7 @@ namespace semantics throw parsing (p, "unsupported changelog format version"); database_ = p.attribute ("database"); + schema_name_ = p.attribute ("schema-name", ""); // Because things are stored in the reverse order, first save the // changesets as XML chunks and then re-parse them in the reverse @@ -128,6 +129,8 @@ namespace semantics s.start_element (xmlns, "changelog"); s.namespace_decl (xmlns, ""); s.attribute ("database", database_); + if (!schema_name_.empty ()) + s.attribute ("schema-name", schema_name_); s.attribute ("version", 1); // Format version. // For better readability serialize things in reverse order so that diff --git a/odb/semantics/relational/changelog.hxx b/odb/semantics/relational/changelog.hxx index a27c946..c740c7c 100644 --- a/odb/semantics/relational/changelog.hxx +++ b/odb/semantics/relational/changelog.hxx @@ -122,8 +122,12 @@ namespace semantics string const& database () const {return database_;} + string const& + schema_name () const {return schema_name_;} + public: - changelog (string const& db): database_ (db), contains_model_ (0) {} + changelog (string const& db, string const& sn) + : database_ (db), schema_name_ (sn), contains_model_ (0) {} changelog (xml::parser&); void @@ -151,6 +155,7 @@ namespace semantics protected: string database_; + string schema_name_; contains_model_type* contains_model_; contains_changeset_list contains_changeset_; }; -- cgit v1.1