Commit b81c8185 authored by Romain Therville's avatar Romain Therville 🐭
Browse files

Update to ng6_database.sql

New check_demand_insert trigger to prevent the insertion of a second
purge demand for a given project.

Issue #192
parent dbad254f
......@@ -1233,6 +1233,34 @@ CREATE ALGORITHM=UNDEFINED DEFINER=`ng6`@`localhost` SQL SECURITY DEFINER VIEW `
CREATE ALGORITHM=UNDEFINED DEFINER=`ng6`@`localhost` SQL SECURITY DEFINER VIEW `tx_nG6_view_project_user` AS select `tx_nG6_project`.`uid` AS `project_id`,`tx_nG6_project`.`space_id` AS `space_id`,`fe_users`.`uid` AS `user_id`, `fe_users`.`username` AS `user_name`,`fe_users`.`email` AS `email`,`fe_users`.`usergroup` AS `user_group`,`fe_rights_levels`.`right_level_label` AS `right_level_label`,`fe_groups`.`title` AS `user_group_title` from ((((`tx_nG6_project` join `fe_rights` on((`fe_rights`.`project_id` = `tx_nG6_project`.`uid`))) join `fe_users` on((`fe_rights`.`fe_user_id` = `fe_users`.`uid`))) join `fe_groups` on((`fe_users`.`usergroup` = `fe_groups`.`uid`))) join `fe_rights_levels` on((`fe_rights_levels`.`right_level_id` = `fe_rights`.`right_id`)));
--
-- Trigger check_demand_insert to prevent the insertion of a second purge demand for a single project
--
DELIMITER ;;
CREATE TRIGGER check_demand_insert BEFORE INSERT ON `tx_nG6_purge_demand`
FOR EACH ROW
BEGIN
DECLARE var_demand_state, var_project_id, var_count int;
SELECT demand_state, project_id, count(*) as count
INTO var_demand_state, var_project_id, var_count
FROM tx_nG6_purge_demand
WHERE demand_state = 'sent' AND project_id = new.project_id
GROUP BY demand_state, project_id;
IF var_count > 0 THEN
set @message_text = concat('A purge demand already exists for project ', new.project_id);
signal sqlstate '45000'
set message_text = @message_text;
END IF;
END;
;;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment