favgroups: convert post_ids from string to array.

This commit is contained in:
evazion
2020-01-14 23:33:55 -06:00
parent eecd9a183d
commit ab325c5d2b
25 changed files with 141 additions and 288 deletions

View File

@@ -0,0 +1,23 @@
class ChangePostIdsToArrayOnFavoriteGroups < ActiveRecord::Migration[6.0]
def up
execute "set statement_timeout = 0"
change_column_default :favorite_groups, :post_ids, nil
change_column :favorite_groups, :post_ids, "integer[]", using: "string_to_array(post_ids, ' ')::integer[]"
change_column_default :favorite_groups, :post_ids, "{}"
add_index :favorite_groups, :post_ids, using: :gin
remove_column :favorite_groups, :post_count
end
def down
execute "set statement_timeout = 0"
remove_index :favorite_groups, :post_ids
change_column_default :favorite_groups, :post_ids, nil
change_column :favorite_groups, :post_ids, :text, using: "array_to_string(post_ids, ' ')"
change_column_default :favorite_groups, :post_ids, ""
add_column :favorite_groups, :post_count, :integer, default: 0, null: false
end
end