Locating realm role's associated attributes in postgres

I can see that the realm roles are under a table called keycloak_role. In the UI I have the associated roles through which I can assign a client role to the realm role. I want to see this in the postgres database. Which other tables should I be looking at. I can find my client role in keycloak_role table as well. Just need to find how then realm role is linked with the client role. Thanks in advance.

See table composite_role.

sweet, got it thanks.

Follow up @dasniko . I want to allocate a client role to a realm role from the database. In order to do this, I’ve found the id of the client role I need to allocate and the id of the role I want to allocate this to and inserted a new row in the composite_role table with the composite column value as the role to which I want to assign the client role to and the child_role value as the client role. But when I go to my keycloak UI I don’t see this reflected as a change (the realm role doesn’t have the client role attache to it). Are there other db actions I need to perform for this to take place? When I remove this row and add the client role from the UI I see the same db row being inserted.

Never work on the DB directly, that’s the last thing you want to do. Always use the API.
Thank me later.

Haha, ok thanks! I’ll do that. But just for my understanding I wanted to try this out and it seems like once I added the row and restarted keycloak the composite_role I added gets picked up. My suspicion is that there is a cache that it reads from.

Yes, Keycloak makes heavy(!) use of a cache. This might lead to inconsistencies when operating directly on the DB and have a running server. Additionally, the data model is a bit complex and if you don’t understand it entirely, you might miss some data/tables/columns. This might not be the case for roles, but other entities.