summaryrefslogtreecommitdiffstats
path: root/src/schema.c
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-07-03 13:59:59 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-07-05 13:32:31 +0200
commit3f02d64104fede43074df2e0f229f514d24363fe (patch)
tree2010f57893ab3a49128bc2a83ddf001bdb471036 /src/schema.c
parent23bd5f1a0703ffa1f6593489b1b544d8306bb82f (diff)
rest: add checksum to GET /images
Add a new checksum attribute to GET /images, extend database to add a new checksum field to images table.
Diffstat (limited to 'src/schema.c')
-rw-r--r--src/schema.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/schema.c b/src/schema.c
index d5a2269..002fd56 100644
--- a/src/schema.c
+++ b/src/schema.c
@@ -306,6 +306,35 @@ static int og_dbi_schema_v6(struct og_dbi *dbi)
return 0;
}
+static int og_dbi_schema_v7(struct og_dbi *dbi)
+{
+ const char *msglog;
+ dbi_result result;
+
+ syslog(LOG_DEBUG, "Adding checksum to imagenes\n");
+ result = dbi_conn_query(dbi->conn,
+ "ALTER TABLE `imagenes` "
+ "ADD `checksum` varchar(128) NOT NULL DEFAULT ''");
+ if (!result) {
+ dbi_conn_error(dbi->conn, &msglog);
+ syslog(LOG_INFO, "Error when adding checksum (%s:%d) %s\n",
+ __func__, __LINE__, msglog);
+ return -1;
+ }
+ dbi_result_free(result);
+
+ result = dbi_conn_query(dbi->conn, "UPDATE version SET version = 7");
+ 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);
@@ -316,6 +345,7 @@ static struct og_schema_version {
{ .version = 4, .update = og_dbi_schema_v4 },
{ .version = 5, .update = og_dbi_schema_v5 },
{ .version = 6, .update = og_dbi_schema_v6 },
+ { .version = 7, .update = og_dbi_schema_v7, },
{ 0, NULL },
};