问题
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