From cae45e130891cf97f93d743ace381eb8209df2a8 Mon Sep 17 00:00:00 2001
From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>
Date: Wed, 12 Jul 2023 09:56:11 +0300
Subject: fix: unique relation for map history and routes

Former-commit-id: f3ea2ce6784973385d63980b6680294bbcee0188
---
 backend/database/init.sql | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'backend/database/init.sql')

diff --git a/backend/database/init.sql b/backend/database/init.sql
index c7d098c..196cb71 100644
--- a/backend/database/init.sql
+++ b/backend/database/init.sql
@@ -49,7 +49,8 @@ CREATE TABLE map_routes (
   showcase TEXT NOT NULL,
   PRIMARY KEY (id),
   FOREIGN KEY (map_id) REFERENCES maps(id),
-  FOREIGN KEY (category_id) REFERENCES categories(id)
+  FOREIGN KEY (category_id) REFERENCES categories(id),
+  UNIQUE (map_id, category_id, score_count)
 );
 
 CREATE TABLE map_history (
@@ -61,7 +62,8 @@ CREATE TABLE map_history (
   record_date TIMESTAMP NOT NULL,
   PRIMARY KEY (id),
   FOREIGN KEY (category_id) REFERENCES categories(id),
-  FOREIGN KEY (map_id) REFERENCES maps(id)
+  FOREIGN KEY (map_id) REFERENCES maps(id),
+  UNIQUE (map_id, category_id, score_count)
 );
 
 CREATE TABLE map_ratings (
-- 
cgit v1.2.3

