fix(coderd/database): allow same custom role name for different orgs (#21312)

Previously the `idx_custom_roles_name_lower` index prevented that.

A check constraint was also added to ensure the `organization_id` column cannot be set to the all-zero UUID.
This commit is contained in:
George K
2026-01-05 07:43:08 -08:00
committed by GitHub
parent 55cc6b807c
commit e10fceb23c
6 changed files with 49 additions and 3 deletions
@@ -0,0 +1,10 @@
-- Fixture for migration 000404_allow_same_role_name_in_different_orgs.
-- Inserts a custom role with an all-zero organization_id to ensure the
-- migration correctly normalizes such values.
INSERT INTO custom_roles (name, display_name, organization_id)
VALUES (
'custom-role-zero-org-id',
'Custom Role (Zero Org ID)',
'00000000-0000-0000-0000-000000000000'::uuid
)
ON CONFLICT DO NOTHING;