MCPcopy
hub / github.com/CapSoftware/Cap / backfillUserDefaultOrgIds

Function backfillUserDefaultOrgIds

packages/database/migrations/orgid_backfill.ts:57–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55}
56
57async function backfillUserDefaultOrgIds() {
58 console.log("👤 Starting user defaultOrgId backfill...");
59
60 let updated = 0;
61
62 const updateResult = await db()
63 .update(users)
64 .set({
65 defaultOrgId: users.activeOrganizationId.getSQL(),
66 })
67 .where(
68 and(isNull(users.defaultOrgId), isNotNull(users.activeOrganizationId)),
69 );
70 const rowsUpdated = updateResult[0].affectedRows || 0;
71 updated += rowsUpdated;
72
73 console.log(`👥 Assigned defaultOrgId to ${updated} users`);
74}
75
76async function validateBackfill(): Promise<void> {
77 console.log("🔍 Validating backfill results...");

Callers 1

runOrgIdBackfillFunction · 0.85

Calls 2

dbFunction · 0.90
updateMethod · 0.80

Tested by

no test coverage detected