[lxc-devel] [lxd/master] lxd/db: Add type column to images source table

stgraber on Github lxc-bot at linuxcontainers.org
Thu Sep 5 21:15:45 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190905/a714a6cc/attachment-0001.bin>
-------------- next part --------------
From a31ba6a8ee5df7a48075ea264ac03be6c03184ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 5 Sep 2019 17:14:55 -0400
Subject: [PATCH] lxd/db: Add type column to images source table
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: St├ęphane Graber <stgraber at ubuntu.com>
---
 lxd/db/cluster/schema.go | 3 ++-
 lxd/db/cluster/update.go | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lxd/db/cluster/schema.go b/lxd/db/cluster/schema.go
index 78534e25b6..4d1ff36704 100644
--- a/lxd/db/cluster/schema.go
+++ b/lxd/db/cluster/schema.go
@@ -73,6 +73,7 @@ CREATE TABLE images_source (
     protocol INTEGER NOT NULL,
     certificate TEXT NOT NULL,
     alias TEXT NOT NULL,
+    type TEXT NOT NULL DEFAULT '',
     FOREIGN KEY (image_id) REFERENCES images (id) ON DELETE CASCADE
 );
 CREATE TABLE "instances" (
@@ -481,5 +482,5 @@ CREATE TABLE storage_volumes_config (
     FOREIGN KEY (storage_volume_id) REFERENCES storage_volumes (id) ON DELETE CASCADE
 );
 
-INSERT INTO schema (version, updated_at) VALUES (17, strftime("%s"))
+INSERT INTO schema (version, updated_at) VALUES (18, strftime("%s"))
 `
diff --git a/lxd/db/cluster/update.go b/lxd/db/cluster/update.go
index 67e9a1ca20..8b478f9f9a 100644
--- a/lxd/db/cluster/update.go
+++ b/lxd/db/cluster/update.go
@@ -52,6 +52,13 @@ var updates = map[int]schema.Update{
 	15: updateFromV14,
 	16: updateFromV15,
 	17: updateFromV16,
+	18: updateFromV17,
+}
+
+// Add image source type column
+func updateFromV17(tx *sql.Tx) error {
+	_, err := tx.Exec("ALTER TABLE images_source ADD COLUMN type TEXT NOT NULL DEFAULT '';")
+	return err
 }
 
 // Add image type column


More information about the lxc-devel mailing list