add: database transactions

This commit is contained in:
Tobias Reisinger 2020-08-15 12:13:03 +02:00
parent 7fa462ef1d
commit 7c6eed8dc2
8 changed files with 119 additions and 30 deletions

View file

@ -27,8 +27,7 @@ terminate(int signum)
mg_mgr_free(&mgr);
sqlite3_close(global_database);
database_free();
router_free();
status_free();
cache_free();
@ -133,26 +132,9 @@ main(int argc, const char** argv)
helper_drop_privileges();
/******************** SETUP DATABASE ********************/
int rc = sqlite3_open(global_config.database, &global_database);
if(rc)
{
LOGGER_CRIT("can't open database: %s\n", sqlite3_errmsg(global_database));
return 1;
}
if(database_migrate())
{
terminate(1);
}
sqlite3_exec(global_database, "PRAGMA foreign_keys = ON", 0, 0, 0);
/******************** INIT COMPONENTS ********************/
database_init();
cache_init();
router_init();
status_init();