create trigger if not exists update_last_updated_users after update on users when OLD.last_updated = NEW.last_updated or OLD.last_updated is null BEGIN update users set last_updated = (select unixepoch()) where id=NEW.id; END; create trigger if not exists insert_user_follows after insert on users BEGIN insert into follows (user) values (NEW.id); END; create trigger if not exists delete_user_follows after delete on users BEGIN delete from follows where user = OLD.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_watch_quests after update on watch_quests when OLD.last_updated = NEW.last_updated or OLD.last_updated is null BEGIN update watch_quests set last_updated = (select unixepoch()) where id=NEW.id; END; create trigger if not exists update_last_updated_follows after update on follows when OLD.last_updated = NEW.last_updated or OLD.last_updated is null BEGIN update follows 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;