salix/db/.archive/232801/00-department.sql

25 lines
652 B
MySQL
Raw Normal View History

2023-05-09 05:11:21 +00:00
alter table `vn`.`department`
add `twoFactor` ENUM ('email') null comment 'Default user two-factor auth type';
drop trigger `vn`.`department_afterUpdate`;
DELIMITER $$
$$
2023-07-06 09:51:04 +00:00
create definer = root@localhost trigger `vn`.`department_afterUpdate`
2023-05-09 05:11:21 +00:00
after update
on department
for each row
BEGIN
IF !(OLD.parentFk <=> NEW.parentFk) THEN
UPDATE vn.department_recalc SET isChanged = TRUE;
END IF;
IF !(OLD.twoFactor <=> NEW.twoFactor) THEN
UPDATE account.user u
JOIN vn.workerDepartment wd ON wd.workerFk = u.id
SET u.twoFactor = NEW.twoFactor
WHERE wd.departmentFk = NEW.id;
END IF;
END;$$
DELIMITER ;