Branchwell

AI Resource Pro / website / code-updates-after-rename.md

Show the source

Code Updates Required After Renaming tool_count to instance_count

If you decide to rename the tool_count column to instance_count, you'll need to update the following files:

Core Files to Update

  1. src/app/admin/dashboard/page.tsx
    • Line ~295: Change .select('id, name, tool_count') to .select('id, name, instance_count')
    • Line ~301: Change categoryCounts[cat.name] = cat.tool_count || 0; to categoryCounts[cat.name] = cat.instance_count || 0;
  2. src/components/admin/ClientCategoryManager.tsx
    • Line ~71: Change tool_count?: number; to instance_count?: number;
    • Line ~290: Change <TableCell className="text-white">{category.tool_count || 0}</TableCell> to <TableCell className="text-white">{category.instance_count || 0}</TableCell>
    • Line ~540-542: Update references from tool_count to instance_count
  3. src/app/api/admin/categories/route.ts
    • Line ~101: Change tool_count: 0, to instance_count: 0,

API Routes That Update Category Counts

  1. src/app/api/tools/route.ts
    • Update references to tool_count to instance_count
  2. src/app/api/tools/[slug]/route.ts
    • Update references to tool_count to instance_count
    • Line ~187: Change .update({ tool_count: supabase.rpc('increment', { row_id: categoryId }) }) to .update({ instance_count: supabase.rpc('increment', { row_id: categoryId }) })
    • Line ~193: Similar update for decrement
  3. src/app/api/admin/tools/[id]/route.ts
    • Update references from tool_count to instance_count

Scripts & Schema Files

  1. scripts/create-supabase-schema.sql
    • Line ~41: Change tool_count INTEGER DEFAULT 0, to instance_count INTEGER DEFAULT 0,
  2. scripts/seed-supabase.ts
    • Update all references from tool_count to instance_count
  3. scripts/migrate-categories-schema.sql
    • Update references if needed
  4. Any other seed or migration scripts that reference the column

Testing Considerations

After making these changes:

  1. Test the admin dashboard to ensure category counts still display correctly
  2. Test adding/removing tools to verify count increments/decrements properly
  3. Verify that the category manager component still works correctly
  4. Run any database seed scripts to ensure they still function properly

This is not an exhaustive list, but covers the main files identified through a code search. There may be other references to tool_count that would need to be updated.