Add ballot_lines_count counter_cache to ballot -> ballot line relationship
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
class Budget
|
class Budget
|
||||||
class Ballot
|
class Ballot
|
||||||
class Line < ApplicationRecord
|
class Line < ApplicationRecord
|
||||||
belongs_to :ballot
|
belongs_to :ballot, counter_cache: :ballot_lines_count
|
||||||
belongs_to :investment, counter_cache: :ballot_lines_count
|
belongs_to :investment, counter_cache: :ballot_lines_count
|
||||||
belongs_to :heading
|
belongs_to :heading
|
||||||
belongs_to :group
|
belongs_to :group
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddBallotLineCounterCachedToBudgetBallots < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :budget_ballots, :ballot_lines_count, :integer, default: 0
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -133,6 +133,7 @@ ActiveRecord::Schema.define(version: 20190411090023) do
|
|||||||
t.integer "budget_id"
|
t.integer "budget_id"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
t.integer "ballot_lines_count", default: 0
|
||||||
t.boolean "physical", default: false
|
t.boolean "physical", default: false
|
||||||
t.integer "poll_ballot_id"
|
t.integer "poll_ballot_id"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user