Closed GoogleCodeExporter closed 9 years ago
#74, #75也适用
http://guides.rubyonrails.org/migrations.html#changing-tables, Chap.5
Frequently I just want to update rows in the database without writing out the
SQL by hand: I’m not using anything specific to the model. One pattern for
this is to define a copy of the model inside the migration itself, for example:
class AddPartNumberToProducts < ActiveRecord::Migration
class Product < ActiveRecord::Base
end
def self.up
...
end
def self.down
...
end
end
The migration has its own minimal copy of the Product model and no longer cares
about the Product model defined in the application.
Original comment by lywan...@gmail.com
on 3 Mar 2011 at 8:34
刘洋搞定
Original comment by LiYuqia...@gmail.com
on 9 Mar 2011 at 2:11
Original issue reported on code.google.com by
cbm...@gmail.com
on 3 Mar 2011 at 2:44