From 72fd2984adee2a8d6d3c9a9be96e81e16d3655b9 Mon Sep 17 00:00:00 2001 From: DanB Date: Thu, 18 Jul 2013 12:30:30 +0200 Subject: [PATCH] Unique keys for actiontriggers and account actions --- data/storage/mysql/create_tariffplan_tables.sql | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/data/storage/mysql/create_tariffplan_tables.sql b/data/storage/mysql/create_tariffplan_tables.sql index ea2bc51c4..ae8fd575a 100644 --- a/data/storage/mysql/create_tariffplan_tables.sql +++ b/data/storage/mysql/create_tariffplan_tables.sql @@ -140,7 +140,8 @@ CREATE TABLE `tp_action_timings` ( `timing_tag` varchar(24) NOT NULL, `weight` DECIMAL(5,2) NOT NULL, PRIMARY KEY (`id`), - KEY `tpid` (`tpid`) + KEY `tpid` (`tpid`), + UNIQUE KEY `unique_action_schedule` (`tpid`,`tag`,`actions_tag`) ); -- @@ -153,13 +154,14 @@ CREATE TABLE `tp_action_triggers` ( `tag` varchar(24) NOT NULL, `balance_tag` varchar(24) NOT NULL, `direction` varchar(8) NOT NULL, + `threshold_type` char(11) NOT NULL, `threshold_value` DECIMAL(5,4) NOT NULL, - `tpid` char(7) NOT NULL, `destination_tag` varchar(24) NOT NULL, `actions_tag` varchar(24) NOT NULL, `weight` DECIMAL(5,2) NOT NULL, PRIMARY KEY (`id`), - KEY `tpid` (`tpid`) + KEY `tpid` (`tpid`), + UNIQUE KEY `unique_trigger_definition` (`tpid`,`tag`,`balance_tag`,`direction`,`threshold_type`,`threshold_value`,`destination_tag`,`actions_tag`) ); -- @@ -176,5 +178,6 @@ CREATE TABLE `tp_account_actions` ( `action_timings_tag` varchar(24), `action_triggers_tag` varchar(24), PRIMARY KEY (`id`), - KEY `tpid` (`tpid`) + KEY `tpid` (`tpid`), + UNIQUE KEY `unique_tp_account` (`tpid`,`tag`,`tenant`,`account`,`direction`) );