ruby-on-railsdbmigrate

Rails aborted migrate command


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!


Solution

  • 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