From 67c58a14f4f356117f42fea368a32359496d46c4 Mon Sep 17 00:00:00 2001
From: Wojtek Kosior <koszko@koszko.org>
Date: Thu, 11 Aug 2022 13:33:06 +0200
Subject: populate data structures based on payloads data loaded from sqlite db

---
 src/hydrilla/proxy/tables.sql | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

(limited to 'src/hydrilla/proxy/tables.sql')

diff --git a/src/hydrilla/proxy/tables.sql b/src/hydrilla/proxy/tables.sql
index 25493d3..2a6cac6 100644
--- a/src/hydrilla/proxy/tables.sql
+++ b/src/hydrilla/proxy/tables.sql
@@ -121,15 +121,11 @@ CREATE TABLE mapping_statuses(
         -- "enabled" determines whether mapping's status is ENABLED,
 	-- DISABLED or NO_MARK.
         enabled            CHAR(1) NOT NULL,
-	enabled_version_id INTEGER NULL,
 	-- "frozen" determines whether an enabled mapping is to be kept in its
 	-- EXACT_VERSION, is to be updated only with versions from the same
 	-- REPOSITORY or is NOT_FROZEN at all.
 	frozen             CHAR(1) NULL,
 
-	CHECK  (NOT (enabled = 'D' AND enabled_version_id IS NOT NULL)),
-	CHECK  (NOT (enabled = 'E' AND enabled_version_id IS NULL)),
-
 	CHECK  ((frozen IS NULL) = (enabled != 'E')),
 	CHECK  (frozen IS NULL OR frozen in ('E', 'R', 'N'))
 );
@@ -143,8 +139,6 @@ CREATE TABLE item_versions(
 	definition          TEXT    NOT NULL,
 
         UNIQUE (item_id, version, repo_iteration_id),
-	-- Allow foreign key from "mapping_statuses".
-	UNIQUE (item_version_id, item_id),
 
 	FOREIGN KEY (item_id)
                 REFERENCES items (item_id),
@@ -226,6 +220,7 @@ CREATE TABLE file_uses(
 
         CHECK (type IN ('L', 'W')),
 	UNIQUE(item_version_id, type, idx),
+	UNIQUE(item_version_id, type, name),
 
         FOREIGN KEY (item_version_id)
                 REFERENCES item_versions(item_version_id)
-- 
cgit v1.2.3

