summaryrefslogtreecommitdiff
path: root/odb/relational/changelog.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-04-03 11:22:42 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-04-10 18:46:44 +0200
commitb0391e168b489811708ca7ba5f71a0eb67b46ffe (patch)
treece15fb5ce0998ec27696152054609bb5dd4f45c3 /odb/relational/changelog.cxx
parente356a9112750e836197a8545bcf6cedad0c1ebe1 (diff)
Generate add/drop table migration statements
Diffstat (limited to 'odb/relational/changelog.cxx')
-rw-r--r--odb/relational/changelog.cxx35
1 files changed, 24 insertions, 11 deletions
diff --git a/odb/relational/changelog.cxx b/odb/relational/changelog.cxx
index 1d536fc..f576c79 100644
--- a/odb/relational/changelog.cxx
+++ b/odb/relational/changelog.cxx
@@ -654,7 +654,8 @@ namespace relational
model_version const& mv,
changelog* old,
std::string const& in_name,
- std::string const& out_name)
+ std::string const& out_name,
+ bool force_init)
{
cutl::shared_ptr<changelog> cl (new (shared) changelog);
graph& g (*cl);
@@ -672,8 +673,9 @@ namespace relational
throw operation_failed ();
}
- cerr << out_name << ": info: initializing changelog with base " <<
- "version " << mv.base << endl;
+ if (!force_init)
+ cerr << out_name << ": info: initializing changelog with base " <<
+ "version " << mv.base << endl;
if (mv.base == mv.current)
g.new_edge<contains_model> (*cl, g.new_node<model> (m, g));
@@ -687,7 +689,10 @@ namespace relational
changeset& c (diff (nm, m, *cl));
if (!c.names_empty ())
+ {
+ g.new_edge<alters_model> (c, nm);
g.new_edge<contains_changeset> (*cl, c);
+ }
}
return cl;
@@ -725,12 +730,11 @@ namespace relational
// changeset.
//
//
- model* base (bver == mv.base ? &g.new_node<model> (oldm, g) : 0);
+ model* last (&g.new_node<model> (oldm, g));
+ model* base (bver == mv.base ? last : 0);
if (base != 0)
g.new_edge<contains_model> (*cl, *base);
- model* last (&oldm);
-
for (changelog::contains_changeset_iterator i (
old->contains_changeset_begin ());
i != old->contains_changeset_end (); ++i)
@@ -743,7 +747,8 @@ namespace relational
if (cs.version () == mv.current)
break;
- last = &patch (*last, cs, g);
+ model& prev (*last);
+ last = &patch (prev, cs, g);
if (base == 0)
{
@@ -762,7 +767,10 @@ namespace relational
changeset& c (diff (*base, *last, *cl));
if (!c.names_empty ())
+ {
+ g.new_edge<alters_model> (c, *base);
g.new_edge<contains_changeset> (*cl, c);
+ }
continue;
}
@@ -780,6 +788,8 @@ namespace relational
? static_cast<qscope&> (*base) // Cannot be NULL.
: cl->contains_changeset_back ().changeset (),
g));
+
+ g.new_edge<alters_model> (c, prev);
g.new_edge<contains_changeset> (*cl, c);
}
@@ -794,7 +804,7 @@ namespace relational
{
// Fast-forward the latest model to the new base.
//
- base = last != &oldm ? last : &g.new_node<model> (oldm, g);
+ base = last;
base->version (mv.base);
}
@@ -835,10 +845,13 @@ namespace relational
//
if (mv.base != mv.current)
{
- changeset& cs (diff (*last, m, *cl));
+ changeset& c (diff (*last, m, *cl));
- if (!cs.names_empty ())
- g.new_edge<contains_changeset> (*cl, cs);
+ if (!c.names_empty ())
+ {
+ g.new_edge<alters_model> (c, *last);
+ g.new_edge<contains_changeset> (*cl, c);
+ }
}
return cl;