Add missing unique constraints for role-right upserts

FixInitializerService
Shipped
April 20, 2026 at 8:06 PM UTC
Author
Kamo
Commit
559376b

**************** + syncSecurityModelRoleRights use `ON CONFLICT (role_id, right_type) DO NOTHING` and `ON CONFLICT (default_role_id, right_type) DO NOTHING`, which require matching unique constraints on the DB tables. The matching `@UniqueConstraint` annotations on `OrgRoleRight` and **************** only take effect on CREATE TABLE, so existing databases never gained them — causing SecurityService startup to fail with `ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification`. Dedupe first in case legacy rows have duplicates that would block the ADD CONSTRAINT, then add both constraints idempotently via SchemaCleanupRunner.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing