OSDN Git Service

シーケンスがおかしくなるのを修正
authorTaro Matsuzawa <tmatsuzawa@kbmj.com>
Mon, 9 Aug 2010 09:37:49 +0000 (18:37 +0900)
committerTaro Matsuzawa <tmatsuzawa@kbmj.com>
Mon, 9 Aug 2010 09:37:49 +0000 (18:37 +0900)
db/migrate/20100809091847_add_retailer_if_dont_have_retailer.rb

index cdfc322..f886ba0 100644 (file)
@@ -4,9 +4,12 @@ class AddRetailerIfDontHaveRetailer < ActiveRecord::Migration
       r = Retailer.find(1)
     rescue ActiveRecord::RecordNotFound
       r = Retailer.new
-      r.id = 1
       r.name = "メイン販売元"
       r.save!
+      if r.id != 1
+        r.id = 1
+        r.save!
+      end
     rescue
       raise ActiveRecord::RecordNotFound
     end