summaryrefslogtreecommitdiffstats
path: root/src/schema.c
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-11-07 09:41:55 +0100
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-11-11 12:29:11 +0100
commit892a8fa2e5a60f2390c74d6bf0599e942a80983c (patch)
treecfd1492a95d45ee8d2284d9f88fe109aa936826b /src/schema.c
parent55179decb79c7bf02662b8287efdd948cf006e94 (diff)
rest: update GET /oglive/list to include oglive data from database
Append oglive info at the end of the array of the "oglive" entry. Each entry defines the name of the oglive and the creation date.
Diffstat (limited to 'src/schema.c')
-rw-r--r--src/schema.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/schema.c b/src/schema.c
index f7fceae..1c2428c 100644
--- a/src/schema.c
+++ b/src/schema.c
@@ -464,6 +464,39 @@ static int og_dbi_schema_v11(struct og_dbi *dbi)
return 0;
}
+static int og_dbi_schema_v12(struct og_dbi *dbi)
+{
+ const char *msglog;
+ dbi_result result;
+
+ syslog(LOG_DEBUG, "Creating table oglive\n");
+ result = dbi_conn_query(dbi->conn, "CREATE TABLE `oglive` ("
+ "`id` BIGINT NOT NULL AUTO_INCREMENT,"
+ "`name` VARCHAR(100),"
+ "`creation_date` DATETIME NOT NULL,"
+ "`is_default` BOOLEAN NOT NULL,"
+ "PRIMARY KEY (`id`)"
+ ")");
+ if (!result) {
+ dbi_conn_error(dbi->conn, &msglog);
+ syslog(LOG_INFO, "Error when creating oglive (%s:%d) %s\n",
+ __func__, __LINE__, msglog);
+ return -1;
+ }
+ dbi_result_free(result);
+
+ result = dbi_conn_query(dbi->conn, "UPDATE version SET version = 12");
+ 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);
@@ -479,6 +512,7 @@ static struct og_schema_version {
{ .version = 9, .update = og_dbi_schema_v9, },
{ .version = 10, .update = og_dbi_schema_v10,},
{ .version = 11, .update = og_dbi_schema_v11,},
+ { .version = 12, .update = og_dbi_schema_v12,},
{ 0, NULL },
};