From de89dc9b4a4ec26dc209ba7edec5e86eb6f0e04e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Mon, 23 Jan 2023 14:41:06 +0100 Subject: [PATCH] sql: forbid same location for part --- schema.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/schema.sql b/schema.sql index ebc2942..7e0bc30 100644 --- a/schema.sql +++ b/schema.sql @@ -134,5 +134,6 @@ CREATE TABLE IF NOT EXISTS inventory ( location INTEGER, quantity INTEGER NOT NULL, FOREIGN KEY (part) REFERENCES part (id), - FOREIGN KEY (location) REFERENCES location (id) + FOREIGN KEY (location) REFERENCES location (id), + UNIQUE (part, location) );