Create DB Schema before DBMaxIDCallback is initialized

Set SQLITE_FOUND so metaserver gets actually built
This commit is contained in:
Daniel Hartl 2018-06-11 21:10:07 -07:00
parent 2e54a8985b
commit 63dd530c11
2 changed files with 10 additions and 11 deletions
cmake/modules
metaserver

View file

@ -18,6 +18,7 @@
if ( SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES )
# in cache already
SET(Sqlite_FIND_QUIETLY TRUE)
SET(SQLITE_FOUND)
endif ( SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES )
# use pkg-config to get the directories and then use these values

View file

@ -144,6 +144,15 @@ int DBInit(void)
return -1;
}
if (doinit) {
errmsg = NULL;
if (sqlite3_exec(DB, SQLCreateTables, NULL, NULL, &errmsg) != SQLITE_OK) {
fprintf(stderr, "SQL error: %s\n", errmsg);
sqlite3_free(errmsg);
return -1;
}
}
errmsg = NULL;
if (sqlite3_exec(DB, "SELECT MAX(id) FROM games;", DBMaxIDCallback, NULL, &errmsg) != SQLITE_OK) {
fprintf(stderr, "SQL error: %s\n", errmsg);
@ -151,17 +160,6 @@ int DBInit(void)
return -1;
}
if (!doinit) {
return 0;
}
errmsg = NULL;
if (sqlite3_exec(DB, SQLCreateTables, NULL, NULL, &errmsg) != SQLITE_OK) {
fprintf(stderr, "SQL error: %s\n", errmsg);
sqlite3_free(errmsg);
return -1;
}
return 0;
}