change column name Rails

后端 未结 4 1589
南旧
南旧 2021-02-02 10:18

I have this table:

class CreateShoes < ActiveRecord::Migration
  def change
    create_table :shoes do |t|
      t.string :name
      t.boolean :leather
              


        
4条回答
  •  失恋的感觉
    2021-02-02 11:11

    Either fix your migration and do

    rake db:rollback db:migrate
    

    or make another migration like so:

    rename_column :shoes, :season, :season_id if column_exists?(:shoes, :season) && !column_exists?(:shoes, :season_id)
    

    and then do

    rake db:migrate
    

提交回复
热议问题