aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2012-09-20 15:32:05 +0100
committerLouise Crow <louise.crow@gmail.com>2012-09-20 15:32:05 +0100
commita9912f68be4a1e07c1cbd1741cbbefd6dfe9852d (patch)
tree02aed5b776c8defcfbf5e89c72e5c77d4a5da3f7 /db
parent905e3ce388f9ffdbe3628efaaca8a27965aa952a (diff)
parentaebcdc082f277b3569d1300ebeda43c503d8aec5 (diff)
Merge remote-tracking branch 'origin/release/0.6.6' into develop
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20120912170035_add_info_requests_count_to_public_bodies.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/db/migrate/20120912170035_add_info_requests_count_to_public_bodies.rb b/db/migrate/20120912170035_add_info_requests_count_to_public_bodies.rb
index d77dbaa64..d187dcfa5 100644
--- a/db/migrate/20120912170035_add_info_requests_count_to_public_bodies.rb
+++ b/db/migrate/20120912170035_add_info_requests_count_to_public_bodies.rb
@@ -2,11 +2,10 @@ class AddInfoRequestsCountToPublicBodies < ActiveRecord::Migration
def self.up
add_column :public_bodies, :info_requests_count, :integer, :null => false, :default => 0
- PublicBody.reset_column_information
+ PublicBody.connection.execute("UPDATE public_bodies
+ SET info_requests_count = (SELECT COUNT(*) FROM info_requests
+ WHERE public_body_id = public_bodies.id);")
- PublicBody.find_each do |public_body|
- public_body.update_attribute :info_requests_count, public_body.info_requests.length
- end
end