Skip to content

Commit eada0d3

Browse files
committed
chore: improve debug logging in role and ability management code
1 parent 4c22fa0 commit eada0d3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ export const createRoles = async <
664664
if (
665665
pgRoles.find((role: { rolname: string }) => role.rolname === roleName)
666666
) {
667-
debug("Role already exists", roleName);
667+
debug("Role already exists", roleName, model, slug);
668668
} else {
669669
await prisma.$transaction([
670670
takeLock(prisma),
@@ -722,6 +722,8 @@ export const createRoles = async <
722722
createAbilityName(ability.model!, ability.slug!),
723723
);
724724

725+
debug("Setting up role", key, role, "with abilities", rlsRoles.join(", "));
726+
725727
// Note: We need to GRANT all on schema public so that we can resolve relation queries with prisma, as they will sometimes use a join table.
726728
// This is not ideal, but because we are using RLS, it's not a security risk. Any table with RLS also needs a corresponding policy for the role to have access.
727729
await prisma.$transaction([
@@ -757,7 +759,7 @@ export const createRoles = async <
757759

758760
if (oldRoles.length) {
759761
// Now revoke old roles from the user role
760-
debug("Revoking old roles", oldRoles.join(", "));
762+
debug("Revoking old roles", key, role, oldRoles.join(", "));
761763
await prisma.$executeRawUnsafe(
762764
`REVOKE ${oldRoles.join(", ")} FROM ${role}`,
763765
);

0 commit comments

Comments
 (0)