diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2021-05-14 10:45:59 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2021-05-26 17:19:30 +0200 |
commit | 12d8fff3efef35aa61777f82133e627030bc0b27 (patch) | |
tree | 9ee62c732703f84cd565d55b68a809466fce1a45 /src/schema.c | |
parent | 10c9559dfc46afd5710b2d49fb61fe5ccafc87d0 (diff) |
#1037 Add disk type
Add ogServer support for parsing and storing in the DB disk type data
from ogClient refresh response.
See also commits with #1037 in ogClient and WebConsole repo.
Diffstat (limited to 'src/schema.c')
-rw-r--r-- | src/schema.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/schema.c b/src/schema.c index efd8339..68c481f 100644 --- a/src/schema.c +++ b/src/schema.c @@ -178,12 +178,50 @@ err_no_trans: return -1; } +static int og_dbi_schema_v3(struct og_dbi *dbi) +{ + const char *msglog, *command; + dbi_result result, result_alter; + + result = dbi_conn_query(dbi->conn, + "ALTER TABLE ordenadores_particiones " + "ADD disk_type VARCHAR(32) DEFAULT NULL " + "AFTER numdisk;"); + + while (dbi_result_next_row(result)) { + command = dbi_result_get_string(result, "cmd"); + + syslog(LOG_DEBUG, "Adding disk type: %s\n", command); + result_alter = dbi_conn_query(dbi->conn, command); + if (!result_alter) { + dbi_conn_error(dbi->conn, &msglog); + syslog(LOG_INFO, "Error when adding disk type (%s:%d) %s\n", + __func__, __LINE__, msglog); + return -1; + } + dbi_result_free(result_alter); + } + dbi_result_free(result); + + result = dbi_conn_query(dbi->conn, "UPDATE version SET version = 3"); + 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); } schema_version[] = { { .version = 1, .update = og_dbi_schema_v1 }, { .version = 2, .update = og_dbi_schema_v2 }, + { .version = 3, .update = og_dbi_schema_v3 }, { 0, NULL }, }; |