Change limit on Weapons/Summons to boolean
This commit is contained in:
parent
10184af964
commit
a6c43d5f57
7 changed files with 62 additions and 0 deletions
17
db/data/20230102160350_migrate_weapon_limit_to_boolean.rb
Normal file
17
db/data/20230102160350_migrate_weapon_limit_to_boolean.rb
Normal 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
|
||||||
19
db/data/20230102161028_migrate_limit_value_to_limit2.rb
Normal file
19
db/data/20230102161028_migrate_limit_value_to_limit2.rb
Normal 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
|
||||||
6
db/migrate/20230102154816_change_limit_to_boolean.rb
Normal file
6
db/migrate/20230102154816_change_limit_to_boolean.rb
Normal 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
|
||||||
5
db/migrate/20230102161702_remove_limit_from_weapons.rb
Normal file
5
db/migrate/20230102161702_remove_limit_from_weapons.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class RemoveLimitFromWeapons < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
remove_column :weapons, :limit, :integer
|
||||||
|
end
|
||||||
|
end
|
||||||
5
db/migrate/20230102161738_rename_limit2_on_weapon.rb
Normal file
5
db/migrate/20230102161738_rename_limit2_on_weapon.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class RenameLimit2OnWeapon < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
rename_column :weapons, :limit2, :limit
|
||||||
|
end
|
||||||
|
end
|
||||||
5
db/migrate/20230102161820_remove_limit_from_summons.rb
Normal file
5
db/migrate/20230102161820_remove_limit_from_summons.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class RemoveLimitFromSummons < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
remove_column :summons, :limit, :integer
|
||||||
|
end
|
||||||
|
end
|
||||||
5
db/migrate/20230102161941_rename_limit2_on_summons.rb
Normal file
5
db/migrate/20230102161941_rename_limit2_on_summons.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class RenameLimit2OnSummons < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
rename_column :summons, :limit2, :limit
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue