[lxc-devel] [lxd/master] lxd/db: Add missing unique key

stgraber on Github lxc-bot at linuxcontainers.org
Thu Dec 12 19:28:19 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/20191212/f7bfc55e/attachment.bin>
-------------- next part --------------
From 5f2a8104b773faddbcea61ef233978eff613567e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 12 Dec 2019 14:27:46 -0500
Subject: [PATCH] lxd/db: Add missing unique key
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/update.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lxd/db/cluster/update.go b/lxd/db/cluster/update.go
index 5e2114197c..a4ffcc1f16 100644
--- a/lxd/db/cluster/update.go
+++ b/lxd/db/cluster/update.go
@@ -66,7 +66,8 @@ CREATE TABLE images_profiles (
 	image_id INTEGER NOT NULL,
 	profile_id INTEGER NOT NULL,
 	FOREIGN KEY (image_id) REFERENCES images (id) ON DELETE CASCADE,
-	FOREIGN KEY (profile_id) REFERENCES profiles (id) ON DELETE CASCADE
+	FOREIGN KEY (profile_id) REFERENCES profiles (id) ON DELETE CASCADE,
+	UNIQUE (image_id, profile_id)
 );
 INSERT INTO images_profiles (image_id, profile_id) 
 	SELECT images.id, profiles.id FROM images


More information about the lxc-devel mailing list