Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 901
NR 15 Avatar asked Jun 25 '26 02:06

NR 15


1 Answers

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
like image 67
Mosaaleb Avatar answered Jun 27 '26 18:06

Mosaaleb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!