From 10f40f451827a0214b9c6235a4f77535ce763090 Mon Sep 17 00:00:00 2001 From: albert Date: Tue, 12 Mar 2013 13:41:10 -0400 Subject: [PATCH] fix script to correct old pool versions --- script/fixes/006.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/script/fixes/006.rb b/script/fixes/006.rb index 205e94806..1630c819d 100644 --- a/script/fixes/006.rb +++ b/script/fixes/006.rb @@ -2,6 +2,8 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment')) +ActiveRecord::Base.connection.execute("set statement_timeout = 0") + Post.where("created_at > '2013-02-01'").find_each do |post| puts "Fixing #{post.id}" post.reload @@ -12,3 +14,8 @@ Post.where("created_at > '2013-02-01'").find_each do |post| post.update_column(:tag_count_copyright, post.tag_count_copyright) post.update_column(:tag_count_character, post.tag_count_character) end + +PoolVersion.where("post_ids like '% 0 %'").find_each do |pool_version| + cleaned_post_ids = pool_version.post_ids.scan(/(\d+) \d+/).join(" ") + pool_version.update_column(:post_ids, cleaned_post_ids) +end