Run a single migration file

后端 未结 11 736
说谎
说谎 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 16:42

    Looks like at least in the latest Rails release (5.2 at the time of writing) there is one more way of filtering the migrations being ran. One can pass a filter in a SCOPE environment variable which would be then used to select migration files.

    Assuming you have two migration files 1_add_foos.rb and 2_add_foos.run_this_one.rb running

    SCOPE=run_this_one rails db:migrate:up
    

    will select and run only 2_add_foos.run_this_one.rb. Keep in mind that all migration files matching the scope will be ran.

提交回复
热议问题