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:
parent
a6c43d5f57
commit
cfe667ac4e
4 changed files with 36 additions and 0 deletions
20
db/data/20230102233527_migrate_ax_type_to_ax.rb
Normal file
20
db/data/20230102233527_migrate_ax_type_to_ax.rb
Normal 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
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
class RenameAxToAxTypeOnWeapons < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
rename_column :weapons, :ax, :ax_type
|
||||
end
|
||||
end
|
||||
5
db/migrate/20230102233457_add_boolean_ax_to_weapons.rb
Normal file
5
db/migrate/20230102233457_add_boolean_ax_to_weapons.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class AddBooleanAxToWeapons < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :weapons, :ax, :boolean
|
||||
end
|
||||
end
|
||||
|
|
@ -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
|
||||
Loading…
Reference in a new issue