From cfe667ac4ec78dd6c78a276cad924150fcc12ce5 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 2 Jan 2023 15:57:29 -0800 Subject: [PATCH] Change AX on Weapons to boolean Moves current column to `ax_type` but we will probably remove it and do series-based matching on the client --- .../20230102233527_migrate_ax_type_to_ax.rb | 20 +++++++++++++++++++ ...2233405_rename_ax_to_ax_type_on_weapons.rb | 5 +++++ ...0230102233457_add_boolean_ax_to_weapons.rb | 5 +++++ ...0102233727_change_ax_ax_type_properties.rb | 6 ++++++ 4 files changed, 36 insertions(+) create mode 100644 db/data/20230102233527_migrate_ax_type_to_ax.rb create mode 100644 db/migrate/20230102233405_rename_ax_to_ax_type_on_weapons.rb create mode 100644 db/migrate/20230102233457_add_boolean_ax_to_weapons.rb create mode 100644 db/migrate/20230102233727_change_ax_ax_type_properties.rb diff --git a/db/data/20230102233527_migrate_ax_type_to_ax.rb b/db/data/20230102233527_migrate_ax_type_to_ax.rb new file mode 100644 index 0000000..e559c43 --- /dev/null +++ b/db/data/20230102233527_migrate_ax_type_to_ax.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class MigrateAxTypeToAx < ActiveRecord::Migration[6.1] + def up + Weapon.all.each do |weapon| + if weapon.ax_type > 0 + weapon.ax = true + elsif weapon.ax_type == 0 + weapon.ax = false + weapon.ax_type = nil + end + + weapon.save + end + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/db/migrate/20230102233405_rename_ax_to_ax_type_on_weapons.rb b/db/migrate/20230102233405_rename_ax_to_ax_type_on_weapons.rb new file mode 100644 index 0000000..d7ce499 --- /dev/null +++ b/db/migrate/20230102233405_rename_ax_to_ax_type_on_weapons.rb @@ -0,0 +1,5 @@ +class RenameAxToAxTypeOnWeapons < ActiveRecord::Migration[6.1] + def change + rename_column :weapons, :ax, :ax_type + end +end diff --git a/db/migrate/20230102233457_add_boolean_ax_to_weapons.rb b/db/migrate/20230102233457_add_boolean_ax_to_weapons.rb new file mode 100644 index 0000000..67b86c0 --- /dev/null +++ b/db/migrate/20230102233457_add_boolean_ax_to_weapons.rb @@ -0,0 +1,5 @@ +class AddBooleanAxToWeapons < ActiveRecord::Migration[6.1] + def change + add_column :weapons, :ax, :boolean + end +end diff --git a/db/migrate/20230102233727_change_ax_ax_type_properties.rb b/db/migrate/20230102233727_change_ax_ax_type_properties.rb new file mode 100644 index 0000000..78c7a78 --- /dev/null +++ b/db/migrate/20230102233727_change_ax_ax_type_properties.rb @@ -0,0 +1,6 @@ +class ChangeAxAxTypeProperties < ActiveRecord::Migration[6.1] + def change + change_column :weapons, :ax, :boolean, null: false, default: false + change_column :weapons, :ax_type, :integer, null: true, default: nil + end +end