From 7f8d874338fbafb35e7b79d17f224da8b918bebb Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Tue, 21 May 2024 15:07:26 +0200 Subject: schema: add cache table to store image files in client Add a new table to store the image file that are stores in the client cache. Use bigint to store file size in bytes. --- src/schema.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/schema.c b/src/schema.c index f1fab5b..d5a2269 100644 --- a/src/schema.c +++ b/src/schema.c @@ -271,6 +271,41 @@ static int og_dbi_schema_v5(struct og_dbi *dbi) return 0; } +static int og_dbi_schema_v6(struct og_dbi *dbi) +{ + const char *msglog; + dbi_result result; + + syslog(LOG_DEBUG, "create table cache\n"); + result = dbi_conn_query(dbi->conn, + "CREATE TABLE `cache` (" + "`cacheid` int NOT NULL AUTO_INCREMENT," + "`clientid` int NOT NULL DEFAULT 0," + "`imagename` varchar(80) NOT NULL DEFAULT ''," + "`size` bigint NOT NULL DEFAULT 0," + "`checksum` varchar(128) NOT NULL DEFAULT ''," + "PRIMARY KEY (`cacheid`)" + ") AUTO_INCREMENT=1;"); + if (!result) { + dbi_conn_error(dbi->conn, &msglog); + syslog(LOG_INFO, "Error when adding identorno (%s:%d) %s\n", + __func__, __LINE__, msglog); + return -1; + } + dbi_result_free(result); + + result = dbi_conn_query(dbi->conn, "UPDATE version SET version = 6"); + if (!result) { + dbi_conn_error(dbi->conn, &msglog); + syslog(LOG_INFO, "Could not update version row (%s:%d) %s\n", + __func__, __LINE__, msglog); + return -1; + } + dbi_result_free(result); + + return 0; +} + static struct og_schema_version { int version; int (*update)(struct og_dbi *dbi); @@ -280,6 +315,7 @@ static struct og_schema_version { { .version = 3, .update = og_dbi_schema_v3 }, { .version = 4, .update = og_dbi_schema_v4 }, { .version = 5, .update = og_dbi_schema_v5 }, + { .version = 6, .update = og_dbi_schema_v6 }, { 0, NULL }, }; -- cgit v1.2.3-18-g5258