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

前端 未结 7 1242
生来不讨喜
生来不讨喜 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 14:18

    Don't know if this applies, but it's worth a shot. Straight from "Agile Development with Rails, 3rd edition":

    Sometimes this schema_migrations table can cause you problems. For example, if you create the migration source file and run db:migrate before you add any schema-defining statements to the file, the database will think it has been updated, and the schema info table will contain the new version number.
    If you then edit that existing migration file and run db:migrate again, Rails won’t know to apply your new changes. In these circumstances, it’s often easiest to drop the database, re-create it, and rerun your migration(s).

    0 讨论(0)
提交回复
热议问题