From 7298968921a638c0c5bdce3ac06a8b759043174d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 24 Apr 2019 08:08:50 +0200 Subject: [PATCH] schema version 2 faction no is a char(4), not an int. --- src/kernel/db/sqlite.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/kernel/db/sqlite.c b/src/kernel/db/sqlite.c index 676dc5028..e92f8cd57 100644 --- a/src/kernel/db/sqlite.c +++ b/src/kernel/db/sqlite.c @@ -3,6 +3,7 @@ #include #include +#include #include "driver.h" @@ -105,7 +106,7 @@ int db_driver_faction_save(dbrow_id * p_id, int no, const char *email, const cha err = sqlite3_reset(stmt); if (err != SQLITE_OK) return err; - err = sqlite3_bind_int(stmt, 1, no); + err = sqlite3_bind_text(stmt, 1, itoa36(no), -1, SQLITE_STATIC); if (err != SQLITE_OK) return err; err = sqlite3_bind_text(stmt, 2, email, -1, SQLITE_STATIC); if (err != SQLITE_OK) return err; @@ -179,10 +180,12 @@ static int db_open_game(const char *dbname) { /* drop deprecated table */ err = sqlite3_exec(g_game_db, "DROP TABLE IF EXISTS `factions`", NULL, NULL, NULL); assert(err == SQLITE_OK); - /* install schema version 1: */ - err = sqlite3_exec(g_game_db, "CREATE TABLE IF NOT EXISTS `faction` (`id` INTEGER PRIMARY KEY, `no` INTEGER NOT NULL UNIQUE, `email` VARCHAR(128), `password` VARCHAR(128))", NULL, NULL, NULL); + } + if (version < 2) { + /* install schema version 2: */ + err = sqlite3_exec(g_game_db, "CREATE TABLE IF NOT EXISTS `faction` (`id` INTEGER PRIMARY KEY, `no` CHAR(4) NOT NULL UNIQUE, `email` VARCHAR(128), `password` VARCHAR(128))", NULL, NULL, NULL); assert(err == SQLITE_OK); - err = sqlite3_exec(g_game_db, "PRAGMA user_version = 1", NULL, NULL, NULL); + err = sqlite3_exec(g_game_db, "PRAGMA user_version = 2", NULL, NULL, NULL); assert(err == SQLITE_OK); } /* create prepared statments: */