Your main problem is that column "domain" of mailboxes is specified as NOT NULL, so of course the "SET NULL" option will not work.
Here is the full message I see when I execute your code, which should
be self explanatory.Here is the full message I see when I execute your code, which should
ERROR: null value in column "domain" violates not-null constraint
DETAIL: Failing row contains (null, null, Hello).
CONTEXT: SQL statement "UPDATE ONLY "public"."mailboxes" SET "username" = NULL, "domain" = NULL WHERE $1 OPERATOR(pg_catalog.=) "username" AND $2 OPERATOR(pg_catalog.=) "domain""
********** Error **********
ERROR: null value in column "domain" violates not-null constraint
SQL state: 23502
Detail: Failing row contains (null, null, Hello).
Context: SQL statement "UPDATE ONLY "public"."mailboxes" SET "username" = NULL, "domain" = NULL WHERE $1 OPERATOR(pg_catalog.=) "username" AND $2 OPERATOR(pg_catalog.=) "domain""