Rails aborted migrate command

若如初见. 提交于 2020-06-28 07:01:54

问题


In trying to do the command $rails db:migrate, I receive the following error:

    $ rails db:migrate RAILS_ENV=test
    rails aborted!
    StandardError: An error has occurred, this and all later migrations canceled:
    Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

How do I specify the release the migration was written for? What file is this in? Thanks!


回答1:


Rails prevent from inheriting from ActiveRecord::Migration that's because migration API can change between different versions.

To solve it provide the version that you need for all your migration files: ActiveRecord::Migration[version_number]

class MigrationClassName < ActiveRecord::Migration[5.2]
end


来源:https://stackoverflow.com/questions/62370391/rails-aborted-migrate-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!