diff --git a/db/migrate/20220315005952_add_weapons_count_to_parties.rb b/db/migrate/20220315005952_add_weapons_count_to_parties.rb new file mode 100644 index 0000000..cbd8e8e --- /dev/null +++ b/db/migrate/20220315005952_add_weapons_count_to_parties.rb @@ -0,0 +1,5 @@ +class AddWeaponsCountToParties < ActiveRecord::Migration[6.1] + def change + add_column :parties, :weapons_count, :integer + end +end diff --git a/db/migrate/20220315011802_populate_party_weapons_count.rb b/db/migrate/20220315011802_populate_party_weapons_count.rb new file mode 100644 index 0000000..ff52183 --- /dev/null +++ b/db/migrate/20220315011802_populate_party_weapons_count.rb @@ -0,0 +1,7 @@ +class PopulatePartyWeaponsCount < ActiveRecord::Migration[6.1] + def up + Party.find_each do |party| + Party.reset_counters(party.id, :weapons) + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 33e1e82..e3f8601 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,14 +10,13 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_03_09_013333) do +ActiveRecord::Schema.define(version: 2022_03_15_005952) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gin" enable_extension "pg_trgm" enable_extension "pgcrypto" enable_extension "plpgsql" - enable_extension "timescaledb" create_table "characters", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name_en" @@ -100,9 +99,6 @@ ActiveRecord::Schema.define(version: 2022_03_09_013333) do t.integer "element" t.index ["party_id"], name: "index_grid_weapons_on_party_id" t.index ["weapon_id"], name: "index_grid_weapons_on_weapon_id" - t.index ["weapon_key1_id"], name: "index_grid_weapons_on_weapon_key1_id" - t.index ["weapon_key2_id"], name: "index_grid_weapons_on_weapon_key2_id" - t.index ["weapon_key3_id"], name: "index_grid_weapons_on_weapon_key3_id" end create_table "oauth_access_grants", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| @@ -153,6 +149,7 @@ ActiveRecord::Schema.define(version: 2022_03_09_013333) do t.text "description" t.uuid "raid_id" t.integer "element" + t.integer "weapons_count" t.index ["user_id"], name: "index_parties_on_user_id" end