Skip to content
Snippets Groups Projects

fix for drop hive_post_tags without assign tags to post during upgrades

Merged Marcin requested to merge mi_upgrade_tags_fault into develop
1 file
+ 14
0
Compare changes
  • Side-by-side
  • Inline
@@ -225,6 +225,20 @@ IF NOT EXISTS(SELECT data_type FROM information_schema.columns
@@ -225,6 +225,20 @@ IF NOT EXISTS(SELECT data_type FROM information_schema.columns
WHERE table_name = 'hive_posts' AND column_name = 'tags_ids') THEN
WHERE table_name = 'hive_posts' AND column_name = 'tags_ids') THEN
ALTER TABLE ONLY hive_posts
ALTER TABLE ONLY hive_posts
ADD COLUMN tags_ids INTEGER[];
ADD COLUMN tags_ids INTEGER[];
 
 
UPDATE hive_posts hp
 
SET
 
tags_ids = tags.tags
 
FROM
 
(
 
SELECT
 
post_id as post_id,
 
array_agg( hpt.tag_id ) as tags
 
FROM
 
hive_post_tags hpt
 
GROUP BY post_id
 
) as tags
 
WHERE hp.id = tags.post_id;
ELSE
ELSE
RAISE NOTICE 'SKIPPING hive_posts upgrade - adding a tags_ids column';
RAISE NOTICE 'SKIPPING hive_posts upgrade - adding a tags_ids column';
END IF;
END IF;
@@ -408,4 +422,4 @@ CREATE INDEX IF NOT EXISTS hive_posts_promoted_id_idx ON hive_posts (promoted, i
@@ -408,4 +422,4 @@ CREATE INDEX IF NOT EXISTS hive_posts_promoted_id_idx ON hive_posts (promoted, i
CREATE INDEX IF NOT EXISTS hive_posts_tags_ids_idx ON hive_posts USING gin(tags_ids gin__int_ops);
CREATE INDEX IF NOT EXISTS hive_posts_tags_ids_idx ON hive_posts USING gin(tags_ids gin__int_ops);
DROP TABLE IF EXISTS hive_post_tags;
--DROP TABLE IF EXISTS hive_post_tags;
Loading