Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(rbac): chunk default-role seed insert to stay under bind-param cap

Andrej365d5759b398
diff --git a/apps/api/src/utils/seed-default-workspace-roles.ts b/apps/api/src/utils/seed-default-workspace-roles.ts
index ff25ec5fe..3be99f609 100644
--- a/apps/api/src/utils/seed-default-workspace-roles.ts
+++ b/apps/api/src/utils/seed-default-workspace-roles.ts
@@ -85,7 +85,15 @@ export async function seedDefaultWorkspaceRoles() {
return;
}
- await db.insert(schema.workspaceRoleTable).values(rows);
+ // Postgres' bind protocol caps parameters at 65535 per query, so insert
+ // in chunks. 6 columns × 1000 rows = 6000 params per batch, leaving ample
+ // headroom even for instances with tens of thousands of workspaces.
+ const BATCH_SIZE = 1000;
+ for (let i = 0; i < rows.length; i += BATCH_SIZE) {
+ await db
+ .insert(schema.workspaceRoleTable)
+ .values(rows.slice(i, i + BATCH_SIZE));
+ }
console.log(
`✅ Seeded ${rows.length} default workspace role row(s) across ${workspaceIds.length} workspace(s).`,
);