diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-04-25 07:35:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-04-25 07:35:45 +0200 |
commit | d78ba3e97cbe0d6c641120d94d47e25b198febfb (patch) | |
tree | 72d4a9ee1677fdd9a0e8ca9f3d5f08779839a227 /odb/schema-catalog.cxx | |
parent | 3b63c05dbbd64db3ebc793cf8eb9003dacfd4cba (diff) |
Add support for schema version table
Diffstat (limited to 'odb/schema-catalog.cxx')
-rw-r--r-- | odb/schema-catalog.cxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/odb/schema-catalog.cxx b/odb/schema-catalog.cxx index 9599afe..137931f 100644 --- a/odb/schema-catalog.cxx +++ b/odb/schema-catalog.cxx @@ -147,6 +147,30 @@ namespace odb if (!pre || m != migrate_both) break; } + + // Update the schema version on the database instance. + // + db.schema_version (v, m == migrate_pre, name); + } + + void schema_catalog:: + migrate (database& db, schema_version v, const std::string& name) + { + schema_version latest (latest_version (db, name)); + + if (v == 0) + v = latest; + else if (v > latest) + throw unknown_schema_version (v); + + for (schema_version i (next_version (db, 0, name)); + i != 0 && i <= v; + i = next_version (db, i, name)) + { + migrate_schema_pre (db, i, name); + // migrate_data (db, i, name); + migrate_schema_post (db, i, name); + } } schema_version schema_catalog:: |