diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-28 13:15:48 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-28 14:26:16 +0200 |
commit | 78a3f9d2223a7c6477036c8bd6fb8a6f188f344f (patch) | |
tree | eb848fc7f6d305c1a43be2097c617628ce072911 /odb/schema-catalog.hxx | |
parent | b4825d95472f8d9e2b9892a56c585a035b6230ac (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).
Diffstat (limited to 'odb/schema-catalog.hxx')
-rw-r--r-- | odb/schema-catalog.hxx | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/odb/schema-catalog.hxx b/odb/schema-catalog.hxx index a58a2dc..c02de4a 100644 --- a/odb/schema-catalog.hxx +++ b/odb/schema-catalog.hxx @@ -63,8 +63,8 @@ namespace odb // Data migration. // public: - // If version is 0, then use the current version and also check whether - // we are in migration. Returns the number of calls made. + // If version is 0, then use the current database version and also + // check whether we are in migration. Returns the number of calls made. // static std::size_t migrate_data (database&, @@ -108,7 +108,7 @@ namespace odb // public: // Migrate both schema and data to the specified version. If version - // is not specified, then migrate to the latest version. + // is not specified, then migrate to the current model version. // static void migrate (database&, schema_version = 0, const std::string& name = ""); @@ -116,33 +116,33 @@ namespace odb // Schema version information. // public: - // Return 0 if current is greater or equal to the latest version. - // If current is not specified, get the current version from the - // database. + // Return the current model version. // static schema_version - next_version (const database& db, - schema_version current = 0, - const std::string& name = "") + current_version (const database& db, const std::string& name = "") { - return next_version (db.id (), - current == 0 ? db.schema_version () : current, - name); + return current_version (db.id (), name); } static schema_version - next_version (database_id, - schema_version current, - const std::string& name = ""); + current_version (database_id, const std::string& name = ""); + // Return current model version + 1 (that is, one past current) if + // the passed version is equal to or greater than current. If the + // version is not specified, then use the current database version. + // static schema_version - latest_version (const database& db, const std::string& name = "") + next_version (const database& db, + schema_version v = 0, + const std::string& name = "") { - return latest_version (db.id (), name); + return next_version (db.id (), v == 0 ? db.schema_version () : v, name); } static schema_version - latest_version (database_id, const std::string& name = ""); + next_version (database_id, + schema_version, + const std::string& name = ""); // Schema existence. // |