mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-09-05 05:58:48 -06:00
![Dessalines](/assets/img/avatar_default.png)
* SQL format checking, 1. * SQL format checking, 2. * SQL format checking, 3. * SQL format checking, 4. * SQL format checking, 5. * Running pg_format * Getting rid of comment. * Upping pg_format version. * Using git ls-files for sql format check. * Fixing sql lints. * Addressing PR comments.
21 lines
502 B
PL/PgSQL
21 lines
502 B
PL/PgSQL
-- This file should undo anything in `up.sql`
|
|
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
|
|
$$;
|
|
|