Branchwell

AI Resource Pro / website · airesourcepro.com / scripts / remove-tags-column.sql

Raw 442 B on 6c7ce85c3441baadd17890ab9cc9bf8ed5112901
1-- First ensure all tags have been migrated
2DO $$
3BEGIN
4 -- Check if there are any posts with non-empty tags
5 IF EXISTS (
6 SELECT 1
7 FROM posts
8 WHERE tags IS NOT NULL
9 AND array_length(tags, 1) > 0
10 ) THEN
11 RAISE EXCEPTION 'There are still posts with tags that have not been migrated to categories';
12 END IF;
13
14 -- If we get here, it's safe to remove the tags column
15 ALTER TABLE posts DROP COLUMN IF EXISTS tags;
16END $$;