summaryrefslogtreecommitdiffstats
path: root/src/schema.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/schema.c')
-rw-r--r--src/schema.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/schema.c b/src/schema.c
index 002fd56..7390e27 100644
--- a/src/schema.c
+++ b/src/schema.c
@@ -335,6 +335,40 @@ static int og_dbi_schema_v7(struct og_dbi *dbi)
return 0;
}
+static int og_dbi_schema_v8(struct og_dbi *dbi)
+{
+ const char *msglog;
+ dbi_result result;
+
+ syslog(LOG_DEBUG, "Creating table image_scope\n");
+ result = dbi_conn_query(dbi->conn, "CREATE TABLE `image_scope` ("
+ "`id` int NOT NULL AUTO_INCREMENT,"
+ "`image_id` int NOT NULL,"
+ "`scope_id` int NOT NULL,"
+ "PRIMARY KEY (`id`),"
+ "FOREIGN KEY (`image_id`) REFERENCES `imagenes` (`idimagen`) ON DELETE CASCADE,"
+ "FOREIGN KEY (`scope_id`) REFERENCES `centros` (`idcentro`) ON DELETE CASCADE"
+ ") AUTO_INCREMENT=1;");
+ if (!result) {
+ dbi_conn_error(dbi->conn, &msglog);
+ syslog(LOG_INFO, "Error when creating image_scope (%s:%d) %s\n",
+ __func__, __LINE__, msglog);
+ return -1;
+ }
+ dbi_result_free(result);
+
+ result = dbi_conn_query(dbi->conn, "UPDATE version SET version = 8");
+ 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);
@@ -346,6 +380,7 @@ static struct og_schema_version {
{ .version = 5, .update = og_dbi_schema_v5 },
{ .version = 6, .update = og_dbi_schema_v6 },
{ .version = 7, .update = og_dbi_schema_v7, },
+ { .version = 8, .update = og_dbi_schema_v8, },
{ 0, NULL },
};