adds counter cache for assignments

This commit is contained in:
Juanjo Bazán
2016-02-25 18:23:17 +01:00
parent 0e1e0ce371
commit 96e5be60a3
3 changed files with 11 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
class ValuationAssignment < ActiveRecord::Base
belongs_to :valuator
belongs_to :spending_proposal
belongs_to :spending_proposal, counter_cache: true
end

View File

@@ -0,0 +1,5 @@
class AddAssignmentsCounterCacheToSpendingProposal < ActiveRecord::Migration
def change
add_column :spending_proposals, :valuation_assignments_count, :integer, default: 0
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160224123110) do
ActiveRecord::Schema.define(version: 20160225171916) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -308,6 +308,7 @@ ActiveRecord::Schema.define(version: 20160224123110) do
t.boolean "valuation_finished", default: false
t.text "explanations_log"
t.integer "administrator_id"
t.integer "valuation_assignments_count", default: 0
end
add_index "spending_proposals", ["author_id"], name: "index_spending_proposals_on_author_id", using: :btree