From f9f952782ce9afa6229c4f85a7884d5a59caf441 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 28 Sep 2013 14:30:05 +0200 Subject: Rework migration API in schema_catalog Specifically: - Rename latest_version() to current_version(). - Change next_version() to return one past current instead of 0 if passed current. - migrate() will now do schema creation if current database version is 0 (no schema). --- odb/relational/schema-source.cxx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'odb/relational') diff --git a/odb/relational/schema-source.cxx b/odb/relational/schema-source.cxx index 54d5076..497520d 100644 --- a/odb/relational/schema-source.cxx +++ b/odb/relational/schema-source.cxx @@ -21,8 +21,7 @@ namespace relational sema_rel::model& model (*ctx.model); string const& schema_name (ops.schema_name ()[db]); - if (log != 0 && - (log->contains_changeset_empty () || ops.suppress_migration ())) + if (log != 0 && ops.suppress_migration ()) log = 0; bool schema_version ( @@ -149,6 +148,19 @@ namespace relational // if (log != 0) { + // Create NULL migration entry for the base version so that we + // get the complete version range (base, current) at runtime. + // Code in schema_catalog relies on this. + // + os << "static const schema_catalog_migrate_entry" << endl + << "migrate_schema_entry_" << log->model ().version () << + "_ (" << endl + << "id_" << db << "," << endl + << context::strlit (schema_name) << "," << endl + << log->model ().version () << "ULL," << endl + << "0);" + << endl; + for (sema_rel::changelog::contains_changeset_iterator i ( log->contains_changeset_begin ()); i != log->contains_changeset_end (); ++i) -- cgit v1.1