Set defaults on summons
Summon FLB, ULB and max_level don't have defaults and can be null, which is bad
This commit is contained in:
parent
0c4ed3e157
commit
b46b1fbfd2
2 changed files with 28 additions and 0 deletions
21
db/data/20230102235227_set_flb_to_false_on_summons.rb
Normal file
21
db/data/20230102235227_set_flb_to_false_on_summons.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SetFlbToFalseOnSummons < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
Summon.all.each do |summon|
|
||||
if summon.flb.nil?
|
||||
summon.flb = false
|
||||
summon.save
|
||||
end
|
||||
|
||||
if summon.ulb.nil?
|
||||
summon.ulb = false
|
||||
summon.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
7
db/migrate/20230102234252_set_defaults_on_summons.rb
Normal file
7
db/migrate/20230102234252_set_defaults_on_summons.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class SetDefaultsOnSummons < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
change_column :summons, :flb, :boolean, null: false, default: false
|
||||
change_column :summons, :ulb, :boolean, null: false, default: false
|
||||
change_column :summons, :max_level, :integer, null: false, default: 100
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue