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
This commit is contained in:
Justin Edmund 2023-01-02 15:57:29 -08:00
parent a6c43d5f57
commit cfe667ac4e
4 changed files with 36 additions and 0 deletions

View file

@ -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

View file

@ -0,0 +1,5 @@
class RenameAxToAxTypeOnWeapons < ActiveRecord::Migration[6.1]
def change
rename_column :weapons, :ax, :ax_type
end
end

View file

@ -0,0 +1,5 @@
class AddBooleanAxToWeapons < ActiveRecord::Migration[6.1]
def change
add_column :weapons, :ax, :boolean
end
end

View file

@ -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