Fix counter caches

This commit is contained in:
Justin Edmund 2023-01-28 01:19:46 -08:00
parent 2c4d8b6fe1
commit 6c084610ad
4 changed files with 13 additions and 3 deletions

View file

@ -2,7 +2,7 @@
class GridCharacter < ApplicationRecord
belongs_to :party,
counter_cache: :weapons_count,
counter_cache: :characters_count,
inverse_of: :characters
validates_presence_of :party

View file

@ -2,7 +2,7 @@
class GridSummon < ApplicationRecord
belongs_to :party,
counter_cache: :weapons_count,
counter_cache: :summons_count,
inverse_of: :summons
validates_presence_of :party

View file

@ -0,0 +1,6 @@
class AddCharacterAndSummonCountsToParty < ActiveRecord::Migration[7.0]
def change
add_column :parties, :characters_count, :integer
add_column :parties, :summons_count, :integer
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2023_01_26_040207) do
ActiveRecord::Schema[7.0].define(version: 2023_01_28_091710) do
# These are extensions that must be enabled in order to support this database
enable_extension "btree_gin"
enable_extension "pg_trgm"
@ -154,6 +154,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_26_040207) do
t.integer "order"
t.uuid "base_job_id"
t.string "granblue_id"
t.boolean "accessory", default: false
t.integer "accessory_type", default: 0
t.index ["base_job_id"], name: "index_jobs_on_base_job_id"
end
@ -221,6 +223,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_26_040207) do
t.integer "turn_count"
t.uuid "source_party_id"
t.uuid "accessory_id"
t.integer "characters_count"
t.integer "summons_count"
t.index ["accessory_id"], name: "index_parties_on_accessory_id"
t.index ["job_id"], name: "index_parties_on_job_id"
t.index ["skill0_id"], name: "index_parties_on_skill0_id"