AI Resource Pro / website / code-updates-after-rename.md
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
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;tocategoryCounts[cat.name] = cat.instance_count || 0;
- Line ~295: Change
src/components/admin/ClientCategoryManager.tsx- Line ~71: Change
tool_count?: number;toinstance_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_counttoinstance_count
- Line ~71: Change
src/app/api/admin/categories/route.ts- Line ~101: Change
tool_count: 0,toinstance_count: 0,
- Line ~101: Change
API Routes That Update Category Counts
src/app/api/tools/route.ts- Update references to
tool_counttoinstance_count
- Update references to
src/app/api/tools/[slug]/route.ts- Update references to
tool_counttoinstance_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
- Update references to
src/app/api/admin/tools/[id]/route.ts- Update references from
tool_counttoinstance_count
- Update references from
Scripts & Schema Files
scripts/create-supabase-schema.sql- Line ~41: Change
tool_count INTEGER DEFAULT 0,toinstance_count INTEGER DEFAULT 0,
- Line ~41: Change
scripts/seed-supabase.ts- Update all references from
tool_counttoinstance_count
- Update all references from
scripts/migrate-categories-schema.sql- Update references if needed
- Any other seed or migration scripts that reference the column
Testing Considerations
After making these changes:
- Test the admin dashboard to ensure category counts still display correctly
- Test adding/removing tools to verify count increments/decrements properly
- Verify that the category manager component still works correctly
- 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.