Change limit on Weapons/Summons to boolean

This commit is contained in:
Justin Edmund 2023-01-02 15:56:54 -08:00
parent 10184af964
commit a6c43d5f57
7 changed files with 62 additions and 0 deletions

View file

@ -0,0 +1,17 @@
# frozen_string_literal: true
class MigrateLimitToBoolean < ActiveRecord::Migration[6.1]
def up
Weapon.all.each do |weapon|
weapon.limit2 = weapon.limit > 0
end
Summon.all.each do |summon|
summon.limit2 = summon.limit > 0
end
end
def down
raise ActiveRecord::IrreversibleMigration
end
end

View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
class MigrateLimitValueToLimit2 < ActiveRecord::Migration[6.1]
def up
Weapon.all.each do |weapon|
weapon.limit2 = !(weapon.limit == 0)
weapon.save
end
Summon.all.each do |summon|
summon.limit2 = !(summon.limit == 0)
summon.save
end
end
def down
# raise ActiveRecord::IrreversibleMigration
end
end

View file

@ -0,0 +1,6 @@
class ChangeLimitToBoolean < ActiveRecord::Migration[6.1]
def change
add_column :weapons, :limit2, :boolean, default: false, null: false
add_column :summons, :limit2, :boolean, default: false, null: false
end
end

View file

@ -0,0 +1,5 @@
class RemoveLimitFromWeapons < ActiveRecord::Migration[6.1]
def change
remove_column :weapons, :limit, :integer
end
end

View file

@ -0,0 +1,5 @@
class RenameLimit2OnWeapon < ActiveRecord::Migration[6.1]
def change
rename_column :weapons, :limit2, :limit
end
end

View file

@ -0,0 +1,5 @@
class RemoveLimitFromSummons < ActiveRecord::Migration[6.1]
def change
remove_column :summons, :limit, :integer
end
end

View file

@ -0,0 +1,5 @@
class RenameLimit2OnSummons < ActiveRecord::Migration[6.1]
def change
rename_column :summons, :limit2, :limit
end
end