I am using casbin prisma adapter, I noticed that when I call save policy it recreates all the raws, if you can see here from the first photo to the second the index of primary column has changed, looks like it has auto created all the policies and add the a news one. ( there were 49 policies on the first phot, there are 50 on the second) .
Setup is simple:
@Global()
@Module({
exports: [RbacService, "ENFORCER_SERVICE"],
providers: [
DefaultRolePermissionSeed,
RbacService,
{
provide: "ENFORCER_SERVICE",
useFactory: async () => {
const adapter: PrismaAdapter = await PrismaAdapter.newAdapter();
const enforcer: Enforcer = await newEnforcer(join(__dirname, "rbac.model.conf"), adapter);
enforcer.enableLog(true);
return enforcer;
},
},
],
})
export class RbacModule {}
simple seeding script:
const initialPolicies = DefaultMAPolicies.concat(
DefaultOOPolicies,
DefaultOAPolicies,
DefaultSAPolicies,
DefaultTCHPolicies,
DefaultSTPolicies,
);
const policyExistenceResult = await Promise.all(
initialPolicies.map(async (policy) => {
const exists = await this.rbacService.DoesPolicyExists(policy);
return { exists, policy };
}),
);
console.log(policyExistenceResult);
await this.rbacService.GrantPermissionBulk(policyExistenceResult.filter((p) => !p.exists).map((p) => p.policy));
}
"casbin": "^5.27.1",
"casbin-prisma-adapter": "^1.4.0",
Is something wrong here or is the intended behaviour
Before_Adding_one_policy
After_Adding_one_policy
