Rails: I update migration file then run db:migrate, but my schema isn't updating

前端 未结 7 1292
生来不讨喜
生来不讨喜 2020-12-24 13:27

I\'m trying to add an extra field to one of my tables.

I\'ve added the field in the migration file (under db\\migrate), then ran \'rake db:migrate\' which ran withou

7条回答
  •  悲哀的现实
    2020-12-24 13:54

    http://guides.rubyonrails.org/migrations.html#changing-existing-migrations

    Occasionally you will make a mistake when writing a migration. If you have already run the migration then you cannot just edit the migration and run the migration again: Rails thinks it has already run the migration and so will do nothing when you run rake db:migrate. You must rollback the migration (for example with rake db:rollback), edit your migration and then run rake db:migrate to run the corrected version.

提交回复
热议问题