aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/schema-catalog.cxx14
-rw-r--r--odb/schema-catalog.hxx5
2 files changed, 13 insertions, 6 deletions
diff --git a/odb/schema-catalog.cxx b/odb/schema-catalog.cxx
index 8a5ce71..15cdcb9 100644
--- a/odb/schema-catalog.cxx
+++ b/odb/schema-catalog.cxx
@@ -194,13 +194,13 @@ namespace odb
db.schema_version_migration (v, m == migrate_pre, name);
}
- void schema_catalog::
+ size_t schema_catalog::
migrate_data (database& db, schema_version v, const string& name)
{
if (v == 0)
{
if (!db.schema_migration ())
- return;
+ return 0;
v = db.schema_version ();
}
@@ -209,16 +209,22 @@ namespace odb
data_map::const_iterator i (c.data.find (data_key (name, v)));
if (i == c.data.end ())
- return; // No data migration for this schema/version.
+ return 0; // No data migration for this schema/version.
- const data_functions& df (i->second);
+ size_t r (0);
+ const data_functions& df (i->second);
for (data_functions::const_iterator i (df.begin ()), e (df.end ());
i != e; ++i)
{
if (i->id == id_common || i->id == db.id ())
+ {
i->migrate (db);
+ r++;
+ }
}
+
+ return r;
}
void schema_catalog::
diff --git a/odb/schema-catalog.hxx b/odb/schema-catalog.hxx
index 5af7c48..a58a2dc 100644
--- a/odb/schema-catalog.hxx
+++ b/odb/schema-catalog.hxx
@@ -10,6 +10,7 @@
#include <odb/details/config.hxx> // ODB_CXX11
#include <string>
+#include <cstddef> // std::size_t
#ifdef ODB_CXX11
# include <functional> // std::function
@@ -63,9 +64,9 @@ namespace odb
//
public:
// If version is 0, then use the current version and also check whether
- // we are in migration.
+ // we are in migration. Returns the number of calls made.
//
- static void
+ static std::size_t
migrate_data (database&,
schema_version = 0,
const std::string& name = "");