`
jn615
  • 浏览: 100423 次
  • 性别: Icon_minigender_1
  • 来自: 火星
社区版块
存档分类
最新评论

RAILS: FORCE MIGRATION

阅读更多
Suppose you already have a database with a table named candy and now you want to start using migrations. If you try to run a migration with a pre-existing table, Rails will error. So by placing :force => true, you are forcefully wiping the table. After you've performed your migration, you normally want to return the Boolean to false.

class CreateCandy < ActiveRecord::Migration
  def self.up
    create_table :candies, :force => true do |t|
      t.string :name
      t.string :type
 
      t.timestamps
    end
  end
 
  def self.down
    drop_table :candies
  end
end
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics