From 7d74d42c79fb2747e42b4d9e2743abbc86a5354c Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Mon, 19 Apr 2021 09:26:31 +0000 Subject: #1042 Update database schema automatically This patch adds database schema management capabilities to ogServer: - ogServer now tracks the version of its database schema, if no version is detected, creates a 'version' table with a single row starting at 0. - ogServer can upgrade its database schema to a newer version if detected. (ogServer ships required SQL commands to do so) If ogServer is unable to upgrade the schema at startup (if needed be) it *will not* start. Defines schema update v1 which upgrades database engine tables of ogServer database (usually named 'ogAdmBD') from myISAM to innoDB. --- src/main.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 36b2fe0..ea04a2b 100644 --- a/src/main.c +++ b/src/main.c @@ -87,6 +87,9 @@ int main(int argc, char *argv[]) ev_io_init(&ev_io_agent_rest, og_server_accept_cb, socket_agent_rest, EV_READ); ev_io_start(og_loop, &ev_io_agent_rest); + if (og_dbi_schema_update() < 0) + exit(EXIT_FAILURE); + if (og_dbi_schedule_get() < 0) { syslog(LOG_ERR, "Cannot connect to database\n"); exit(EXIT_FAILURE); -- cgit v1.2.3-18-g5258