db.c: Move the schema revision check after creating the tables
When starting the first time there are no tables, doing a revision
check will fail and bsc_hack will exit without tables created. Do
the revision check within db_prepare and allow new tables to be
created before.
diff --git a/openbsc/src/db.c b/openbsc/src/db.c
index 90bee69..9ad39d3 100644
--- a/openbsc/src/db.c
+++ b/openbsc/src/db.c
@@ -161,12 +161,6 @@
if (dbi_conn_connect(conn) < 0)
goto out_err;
- if (check_db_revision() < 0) {
- fprintf(stderr, "Database schema revision invalid, "
- "please update your database schema\n");
- goto out_err;
- }
-
return 0;
out_err:
@@ -190,6 +184,12 @@
dbi_result_free(result);
}
+ if (check_db_revision() < 0) {
+ fprintf(stderr, "Database schema revision invalid, "
+ "please update your database schema\n");
+ return -1;
+ }
+
return 0;
}