3

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 Answer 1

6

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
Sign up to request clarification or add additional context in comments.

4 Comments

Hi thank you for this! I didn't receive a notification to this question. As I've said, I'm very new to this... where exactly do I add this line? What file?
Add it to all files inside db/migrate. Just add the version at the end of every ActiveRecord::Migration. Also, what Rails version you use? what is the value of executing ActiveRecord::Migration.current_version in Rails console?
Thank you! That helped and executed the command successfully!
Also, I'm using ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.