From 97d1edb408917ccfb2f210f3054fb89213c93da8 Mon Sep 17 00:00:00 2001 From: Alejandro Bernal Date: Wed, 16 Sep 2026 11:41:15 -0500 Subject: [PATCH] CXH-2461: enforce unique role_name in Postgres test fixture The shipped Postgres specs key the role resource id on role_name (id: ".role_name") and build feature-grant entitlement ids as 'role:' + .role_name + ':member', both assuming role_name is unique. The roles table had no UNIQUE constraint, so re-applying the init script against an existing DB appended a second admin/user/reader set, producing two role_name='user' rows and an ambiguous role:user:member entitlement that blocked the grant_replace path. Add UNIQUE to roles.role_name (matching sqlserver-init.sql) so a duplicate role name is rejected at the schema level and each role maps 1:1 to an entitlement. --- test/postgres-init.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/postgres-init.sql b/test/postgres-init.sql index 029bff38..bab9dc84 100644 --- a/test/postgres-init.sql +++ b/test/postgres-init.sql @@ -72,7 +72,7 @@ UPDATE users SET manager_id = (SELECT id FROM users WHERE username = 'robert.tab -- Create roles table CREATE TABLE roles ( id SERIAL PRIMARY KEY, - role_name VARCHAR(100) NOT NULL + role_name VARCHAR(100) NOT NULL UNIQUE ); -- Insert sample roles