-- --------------------------------------------------------
-- Update sod_rule use null values if the value is not used
-- --------------------------------------------------------

ALTER TABLE sod_rule 
CHANGE COLUMN text_response_id text_response_id INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN approver_id approver_id INT(11) NULL DEFAULT NULL ,
CHANGE COLUMN approver_minimum approver_minimum INT(11) NULL DEFAULT NULL ;

UPDATE sod_rule SET text_response_id = NULL WHERE warning_id = 0;
UPDATE sod_rule SET approver_id = NULL WHERE warning_id <> 2;
UPDATE sod_rule SET approver_minimum = NULL WHERE warning_id <> 4;

DELETE FROM sod_text_responses WHERE id = '0';
DELETE FROM sod_approvers WHERE id = '0';