Foreign key errors may arrive as RestrictViolation
Depending on the PostgreSQL version, foreign key violations can be raised as RESTRICT violations. The ORM now treats both the same way, and custom code catching only ForeignKeyViolation should do the same.
On the upgrade checklist: 18.0 → 19.0