Rails 已中止迁移命令

Rails aborted migrate command

在尝试执行命令 $rails db:migrate 时,我收到以下错误:

    $ 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:

如何指定编写迁移的版本?这个在什么文件里?谢谢!

Rails 防止从 ActiveRecord::Migration 继承,这是因为迁移 API 可以在不同版本之间更改。

要解决此问题,请提供所有迁移文件所需的版本: ActiveRecord::Migration[version_number]

class MigrationClassName < ActiveRecord::Migration[5.2]
end