Rake db:migrate error “don't know how to build task”

后端 未结 3 1863
温柔的废话
温柔的废话 2021-01-20 04:43

I\'ve got a table where I used integer on a field which needs decimal places, so I\'m trying to create a migration which changes the field type from integer to float/real. M

相关标签:
3条回答
  • 2021-01-20 04:57

    Your rake call has instructed rake to build the task db:migrate followed by the task change_measure_column_on_ingredients which clearly isn't want you want as the latter is not a rake task.

    To run a specific migration you need to provide the VERSION of the migration. This is the number in the file name which comes before your name for the migration. You can migrate it up or down like this:

    rake db:migrate:down VERSION=123456789
    rake db:migrate:up VERSION=123456789
    

    Alternatively you can take the last migration down then up by doing the following (you can also specify a VERSION for this):

    rake db:migrate:redo
    

    There are other options though. If you run rake --describe db:migrate you'll get some more information.

    0 讨论(0)
  • 2021-01-20 05:09

    make sure your command is rake db:migrate . Pay attention to there is no any space between : and migrate

    0 讨论(0)
  • 2021-01-20 05:19

    While in this specific instance the stacktrace posted by OP shows the error is trying to do two tasks at once, I found this page after googling and just want to add to the answer for future googlers:

    try including either RAILS_ENV=development or RAILS_ENV=test as that is what fixed it for me.

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