From b46b1fbfd23c7f466292a70b873cefe043c2c2ca Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 2 Jan 2023 15:58:12 -0800 Subject: [PATCH] Set defaults on summons Summon FLB, ULB and max_level don't have defaults and can be null, which is bad --- ...30102235227_set_flb_to_false_on_summons.rb | 21 +++++++++++++++++++ .../20230102234252_set_defaults_on_summons.rb | 7 +++++++ 2 files changed, 28 insertions(+) create mode 100644 db/data/20230102235227_set_flb_to_false_on_summons.rb create mode 100644 db/migrate/20230102234252_set_defaults_on_summons.rb diff --git a/db/data/20230102235227_set_flb_to_false_on_summons.rb b/db/data/20230102235227_set_flb_to_false_on_summons.rb new file mode 100644 index 0000000..96f4434 --- /dev/null +++ b/db/data/20230102235227_set_flb_to_false_on_summons.rb @@ -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 diff --git a/db/migrate/20230102234252_set_defaults_on_summons.rb b/db/migrate/20230102234252_set_defaults_on_summons.rb new file mode 100644 index 0000000..f9307e4 --- /dev/null +++ b/db/migrate/20230102234252_set_defaults_on_summons.rb @@ -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