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.
master
OpenGnSys Support Team 2024-05-21 15:07:26 +02:00
parent b63bbfd832
commit 7f8d874338
1 changed files with 36 additions and 0 deletions

View File

@ -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 },
};