aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-09-28 14:30:05 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-09-28 14:30:05 +0200
commitf9f952782ce9afa6229c4f85a7884d5a59caf441 (patch)
treefd5fa92a0937d23b34a2dcff33895d5ae7ed18af
parent12aa1b18d99b51e513e9e82c0ed45717d7538ca0 (diff)
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).
-rw-r--r--odb/relational/schema-source.cxx16
1 files changed, 14 insertions, 2 deletions
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)