# 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 `{category.tool_count || 0}` to `{category.instance_count || 0}`
- 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
4. `src/app/api/tools/route.ts`
- Update references to `tool_count` to `instance_count`
5. `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
6. `src/app/api/admin/tools/[id]/route.ts`
- Update references from `tool_count` to `instance_count`
## Scripts & Schema Files
7. `scripts/create-supabase-schema.sql`
- Line ~41: Change `tool_count INTEGER DEFAULT 0,` to `instance_count INTEGER DEFAULT 0,`
8. `scripts/seed-supabase.ts`
- Update all references from `tool_count` to `instance_count`
9. `scripts/migrate-categories-schema.sql`
- Update references if needed
10. 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.