Branchwell

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

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 $$;