Update 20230102160350_migrate_limit_to_boolean.rb
This commit is contained in:
parent
e50dbeb9aa
commit
cb810b3fd5
1 changed files with 14 additions and 7 deletions
|
|
@ -3,15 +3,22 @@
|
|||
class MigrateLimitToBoolean < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
Weapon.all.each do |weapon|
|
||||
weapon.limit2 = weapon.limit > 0
|
||||
if weapon.limit && weapon.limit > 0
|
||||
weapon.limit2 = true
|
||||
else
|
||||
weapon.limit2 = false
|
||||
end
|
||||
end
|
||||
|
||||
Summon.all.each do |summon|
|
||||
summon.limit2 = summon.limit > 0
|
||||
if summon.limit && summon.limit > 0
|
||||
summon.limit2 = true
|
||||
else
|
||||
summon.limit2 = false
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue