Recently I got a question about rails3.1's migration.Here is the one of the migration file code.
def change
  create_table :books do |t|
    t.string :title
    t.decimal :price
  end
end
Now I need to add a foreign key, let's say comment_id, I used to create another migration and use add_column method in it to get it done.
But since we are in rail3.1,so I thought there might be a new way to do it.so I alter the code
def change
  create_table :books do |t|
    t.string :title
    t.decimal :price
    t.references :comment
  end
end
OK,now I run rake db:migrate and nothin开发者_JAVA百科g happens. Any idea?
did you run rake db:rollback before running rake db:migrate?  You need to roll back the migration before reapplying it with the changes.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论