summaryrefslogtreecommitdiffstats
path: root/src/schema.c
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-05-21 15:07:26 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-05-29 17:19:18 +0200
commit7f8d874338fbafb35e7b79d17f224da8b918bebb (patch)
treef2e01095d9334f0357a9ba101db328752f011458 /src/schema.c
parentb63bbfd8326ef6f9bfa97605b8b728a77f60df97 (diff)
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.
Diffstat (limited to 'src/schema.c')
-rw-r--r--src/schema.c36
1 files changed, 36 insertions, 0 deletions
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 },
};