aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2021-07-23 21:34:34 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-08-04 13:23:48 +0300
commit562fee6a0ce42f6dd2d6acbc7d88dc9b00f50d0e (patch)
treec2a3f6944266063440d2b33e5d6e94f34f3a8758
parent4db621c4cb73a0f53e38ec33665254990c5285f3 (diff)
Before database migration verify that schema in not too old or new
-rw-r--r--bdep/database.cxx14
1 files changed, 13 insertions, 1 deletions
diff --git a/bdep/database.cxx b/bdep/database.cxx
index 064f9ed..7fd375c 100644
--- a/bdep/database.cxx
+++ b/bdep/database.cxx
@@ -125,7 +125,19 @@ namespace bdep
{
// Migrate the database if necessary.
//
- schema_catalog::migrate (db);
+ odb::schema_version sv (db.schema_version ());
+ odb::schema_version scv (schema_catalog::current_version (db));
+
+ if (sv != scv)
+ {
+ if (sv < schema_catalog::base_version (db))
+ fail << "project " << d << " is too old";
+
+ if (sv > scv)
+ fail << "project " << d << " is too new";
+
+ schema_catalog::migrate (db);
+ }
}
t.commit ();