hensei-api/db/data/20260104000002_populate_max_exorcism_level.rb
Justin Edmund 34e3bbd03b
add max_exorcism_level to weapons (#205)
* add max_exorcism_level to weapons

- migration to add column (nullable integer)
- expose in blueprint
- permit in controller
- add spec for create/update

* default exorcism_level=1 for befoulment weapons

- set default on create for GridWeapon and CollectionWeapon
- data migration to populate existing befoulment weapons
- add specs for default behavior
2026-01-04 14:47:16 -08:00

20 lines
593 B
Ruby

# frozen_string_literal: true
class PopulateMaxExorcismLevel < ActiveRecord::Migration[8.0]
def up
# Set max_exorcism_level = 5 for all weapons that belong to a series with befoulment augment type
updated = Weapon
.joins(:weapon_series)
.where(weapon_series: { augment_type: :befoulment })
.update_all(max_exorcism_level: 5)
puts " Updated #{updated} weapons with max_exorcism_level = 5"
end
def down
Weapon
.joins(:weapon_series)
.where(weapon_series: { augment_type: :befoulment })
.update_all(max_exorcism_level: nil)
end
end