2023-07-03 18:13:53 +00:00
|
|
|
-- This file should undo anything in `up.sql`
|
2023-08-02 16:44:51 +00:00
|
|
|
CREATE OR REPLACE FUNCTION was_removed_or_deleted (TG_OP text, OLD record, NEW record)
|
|
|
|
RETURNS boolean
|
|
|
|
LANGUAGE plpgsql
|
|
|
|
AS $$
|
|
|
|
BEGIN
|
|
|
|
IF (TG_OP = 'INSERT') THEN
|
|
|
|
RETURN FALSE;
|
|
|
|
END IF;
|
|
|
|
IF (TG_OP = 'DELETE') THEN
|
|
|
|
RETURN TRUE;
|
|
|
|
END IF;
|
|
|
|
RETURN TG_OP = 'UPDATE'
|
|
|
|
AND ((OLD.deleted = 'f'
|
|
|
|
AND NEW.deleted = 't')
|
|
|
|
OR (OLD.removed = 'f'
|
|
|
|
AND NEW.removed = 't'));
|
|
|
|
END
|
|
|
|
$$;
|
2023-07-03 18:13:53 +00:00
|
|
|
|