--up
CREATE OR REPLACE FUNCTION delete_email_verification() RETURNS TRIGGER AS $$
BEGIN
    DELETE FROM email_verifications WHERE email = OLD.email;
    RETURN OLD;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER delete_email_verification_trigger
AFTER DELETE ON users
FOR EACH ROW EXECUTE PROCEDURE delete_email_verification();

--down

DROP TRIGGER delete_email_verification_trigger ON users;
DROP FUNCTION delete_email_verification();
