Merge pull request #1508 from consul/counter_cache_balloting

Ballot_lines counter to investments
This commit is contained in:
Raimond Garcia
2017-05-02 13:47:33 +02:00
committed by GitHub
3 changed files with 8 additions and 2 deletions

View File

@@ -2,7 +2,7 @@ class Budget
class Ballot
class Line < ActiveRecord::Base
belongs_to :ballot
belongs_to :investment
belongs_to :investment, counter_cache: :ballot_lines_count
belongs_to :heading
belongs_to :group
belongs_to :budget

View File

@@ -0,0 +1,5 @@
class AddBallotLineCountToInvestments < ActiveRecord::Migration
def change
add_column :budget_investments, :ballot_lines_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: 20170427145845) do
ActiveRecord::Schema.define(version: 20170428111355) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -144,6 +144,7 @@ ActiveRecord::Schema.define(version: 20170427145845) do
t.string "location"
t.string "organization_name"
t.datetime "unfeasible_email_sent_at"
t.integer "ballot_lines_count", default: 0
end
add_index "budget_investments", ["administrator_id"], name: "index_budget_investments_on_administrator_id", using: :btree