Permalink
Browse files

Move nil-fixing code from migration to separate maintenance rake task

  • Loading branch information...
1 parent 1767d45 commit 8e7430f66e76524aca3e0a54fb124e1f02e6b028 @marktabler marktabler committed May 21, 2013
Showing with 9 additions and 2 deletions.
  1. +0 −2 db/migrate/20130516220912_add_default_to_inventory_quantities.rb
  2. +9 −0 lib/tasks/maintenance.rake
@@ -2,8 +2,6 @@ class AddDefaultToInventoryQuantities < ActiveRecord::Migration
def up
change_column_default(:shop_inventory_items, :quantity, 0)
change_column_default(:character_inventory_items, :quantity, 0)
- CharacterInventoryItem.where(quantity: nil).update_all(quantity: 0)
- ShopInventoryItem.where(quantity: nil).update_all(quantity: 0)
end
def down
@@ -0,0 +1,9 @@
+namespace :maintenance do
+
+ desc "set nil quantities to 0"
+ task :fix_nil_quantities do
+ CharacterInventoryItem.where(quantity: nil).update_all(quantity: 0)
+ ShopInventoryItem.where(quantity: nil).update_all(quantity: 0)
+ end
+
+end

0 comments on commit 8e7430f

Please sign in to comment.