what2watch/migrations/20230427212229_update_triggers.up.sql

35 lines
1.2 KiB
MySQL
Raw Normal View History

create trigger if not exists update_last_updated_witches
after update on witches
when OLD.last_updated = NEW.last_updated or OLD.last_updated is null
BEGIN
update witches set last_updated = (select unixepoch()) where id=NEW.id;
END;
create trigger if not exists update_last_updated_watches
after update on watches
when OLD.last_updated = NEW.last_updated or OLD.last_updated is null
BEGIN
update watches set last_updated = (select unixepoch()) where id=NEW.id;
END;
create trigger if not exists update_last_updated_witch_watch
after update on witch_watch
when OLD.last_updated = NEW.last_updated or OLD.last_updated is null
BEGIN
update witch_watch set last_updated = (select unixepoch()) where id=NEW.id;
END;
create trigger if not exists update_last_updated_covens
after update on covens
when OLD.last_updated = NEW.last_updated or OLD.last_updated is null
BEGIN
update covens set last_updated = (select unixepoch()) where id=NEW.id;
END;
create trigger if not exists update_last_updated_watch_notes
after update on watch_notes
when OLD.last_updated = NEW.last_updated or OLD.last_updated is null
BEGIN
update watch_notes set last_updated = (select unixepoch()) where id=NEW.id;
END;