summaryrefslogtreecommitdiffstats
path: root/src/schema.c
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-08-21 20:19:23 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-08-21 21:58:48 +0200
commit5eba9f4e1b44fb0d4b4962c2241fe9391e202d7b (patch)
tree1940f98fcf9d24b1046e425b77eddc5bab624ee4 /src/schema.c
parent4e0f9aac9e2883a992469f5b2b231ecb14b30183 (diff)
rest: allow repository to have more than one IP address
Repository can have more than one single IP address. * Add alias field to database to represent the extra IPs that are attached to the repository, update schema and add version 9. * Use og_dbi_get_repository_ip() to infer the repository IP address. * Add helper functions (src/repo.c) to build a list of repositories and update rest API to use it.
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 7390e27..a41f062 100644
--- a/src/schema.c
+++ b/src/schema.c
@@ -369,6 +369,35 @@ static int og_dbi_schema_v8(struct og_dbi *dbi)
return 0;
}
+static int og_dbi_schema_v9(struct og_dbi *dbi)
+{
+ const char *msglog;
+ dbi_result result;
+
+ syslog(LOG_DEBUG, "Adding alias to repositorios\n");
+ result = dbi_conn_query(dbi->conn,
+ "ALTER TABLE `repositorios` "
+ "ADD `alias` int(11) NULL;");
+ if (!result) {
+ dbi_conn_error(dbi->conn, &msglog);
+ syslog(LOG_INFO, "Error when adding alias (%s:%d) %s\n",
+ __func__, __LINE__, msglog);
+ return -1;
+ }
+ dbi_result_free(result);
+
+ result = dbi_conn_query(dbi->conn, "UPDATE version SET version = 9");
+ 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);
@@ -381,6 +410,7 @@ static struct og_schema_version {
{ .version = 6, .update = og_dbi_schema_v6 },
{ .version = 7, .update = og_dbi_schema_v7, },
{ .version = 8, .update = og_dbi_schema_v8, },
+ { .version = 9, .update = og_dbi_schema_v9, },
{ 0, NULL },
};