AI Resource Pro / website / scripts / drop-tool-count-column.sql
| 1 | -- SQL to drop the tool_count column from the categories table if it's no longer needed |
| 2 | |
| 3 | -- First, check if the column exists to prevent errors |
| 4 | DO $$ |
| 5 | BEGIN |
| 6 | IF EXISTS ( |
| 7 | SELECT 1 |
| 8 | FROM information_schema.columns |
| 9 | WHERE table_schema = 'public' |
| 10 | AND table_name = 'categories' |
| 11 | AND column_name = 'tool_count' |
| 12 | ) THEN |
| 13 | -- Drop the column |
| 14 | ALTER TABLE categories |
| 15 | DROP COLUMN tool_count; |
| 16 | |
| 17 | RAISE NOTICE 'Column tool_count has been dropped from categories table'; |
| 18 | ELSE |
| 19 | RAISE NOTICE 'Column tool_count does not exist in categories table'; |
| 20 | END IF; |
| 21 | END $$; |
| 22 | |
| 23 | -- Verify the current structure |
| 24 | SELECT column_name, data_type, is_nullable |
| 25 | FROM information_schema.columns |
| 26 | WHERE table_schema = 'public' |
| 27 | AND table_name = 'categories' |
| 28 | ORDER BY ordinal_position; |