From 60b0bd27fa3e6125dd8a2dd24445f41c5955aa46 Mon Sep 17 00:00:00 2001 From: Ales Raszka Date: Wed, 6 Mar 2019 13:57:11 +0100 Subject: [PATCH] Add namespace_id as constraints to layer_feature If layer contains more than one potential namespace, features will be created for each namespace. Layer_feature table now has to contains one more constrains (namespace_id). --- database/pgsql/migrations/00001_initial_schema.go | 2 +- database/pgsql/queries.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/database/pgsql/migrations/00001_initial_schema.go b/database/pgsql/migrations/00001_initial_schema.go index 85b2b49c..180a1a15 100644 --- a/database/pgsql/migrations/00001_initial_schema.go +++ b/database/pgsql/migrations/00001_initial_schema.go @@ -90,7 +90,7 @@ var ( feature_id INT REFERENCES feature ON DELETE CASCADE, detector_id INT REFERENCES detector ON DELETE CASCADE, namespace_id INT REFERENCES namespace ON DELETE CASCADE, - UNIQUE (layer_id, feature_id));`, + UNIQUE (layer_id, feature_id, namespace_id));`, `CREATE INDEX ON layer_feature(layer_id);`, `CREATE TABLE IF NOT EXISTS layer_namespace ( diff --git a/database/pgsql/queries.go b/database/pgsql/queries.go index 111dc30e..e19f466a 100644 --- a/database/pgsql/queries.go +++ b/database/pgsql/queries.go @@ -121,7 +121,7 @@ func queryPersistFeature(count int) string { func queryPersistLayerFeature(count int) string { return queryPersist(count, "layer_feature", - "layer_feature_layer_id_feature_id_key", + "layer_feature_layer_id_feature_id_namespace_id_key", "layer_id", "feature_id", "detector_id",