ALTER TABLE users ADD COLUMN phantom BOOLEAN DEFAULT FALSE NOT NULL;

CREATE OR REPLACE FUNCTION phantom_check() RETURNS TRIGGER
STRICT VOLATILE AS $$
  BEGIN

    -- Remember who changed the payroll when
    NEW.phantom := (SELECT NEW.email ilike 'phantom+%@jamkazam.com');
    RETURN NEW;
  END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER phantom_update BEFORE INSERT OR UPDATE
ON users FOR EACH ROW EXECUTE PROCEDURE phantom_check(id);

UPDATE users set updated_at = NOW();
