Run a single migration file

后端 未结 11 733
说谎
说谎 2020-11-30 16:01

Is there an easy way to run a single migration? I don\'t want to migrate to a certain version I just want to run a specific one.

11条回答
  •  情歌与酒
    2020-11-30 17:07

    Assuming fairly recent version of Rails you can always run:

    rake db:migrate:up VERSION=20090408054532
    

    Where version is the timestamp in the filename of the migration.

    Edit: At some point over the last 8 years (I'm not sure what version) Rails added checks that prevent this from running if it has already been run. This is indicated by an entry in the schema_migrations table. To re-run it, simply execute rake db:migrate:redo VERSION=20090408054532 instead.

提交回复
热议问题