class AddTimestampsToPosts < ActiveRecord::Migration
def change
add_column :posts, :create_up, :datetime
add_column :posts, :update_at, :datetime
end
end
我需要将:create_up and :update_at
更正为:created_at and :updated_at
我怎样才能做到这一点?
感谢你!
答案 0 :(得分:4)
def change
rename_column :posts, :create_up, :created_at
rename_column :posts, :update_at, :updated_at
end
ActiveRecord::Migration documentation列出了您可以使用的可用转换。