Unable to run migration scripts

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Unable to run migration scripts

Joe Tseng
I've been creating an app using Ruby on Rails on Windows for almost two years and I've had it. This weekend I started migrating my dev environment over to Ubuntu because it can run some tools/services not available in Windows.

I tried to run a migration and I got this error msg:

    $ bundle exec rake db:migrate
    
    rake 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:
    
      class AddAttachmentImportCsvFileToTabClientProjectCommunities < ActiveRecord::Migration[4.2]
    /home/joe/.rvm/gems/ruby-2.3.3/gems/activerecord-5.1.6/lib/active_record/migration.rb:525:in `inherited'
    /home/joe/workspace/asb_base/db/migrate/20170829235908_add_attachment_import_csv_file_to_tab_client_project_communities.rb:1:in `<top (required)>'

I thought maybe it was because the version of RoR I had on Ubuntu (Ruby 2.5.1/Rails 5.2.0) was different than that on Windows (v2.3.3/v5.1.4). I explicitly locked my RoR versions to use what I had in Windows and then ran the migration - still the same error msg. Has anyone else encountered this before?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7d111ada-0764-4978-90db-c88544afd57a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to run migration scripts

Frederick Cheung-2
On Sunday, July 8, 2018 at 5:37:01 PM UTC+2, Joe Tseng wrote:
>

> I thought maybe it was because the version of RoR I had on Ubuntu (Ruby 2.5.1/Rails 5.2.0) was different than that on Windows (v2.3.3/v5.1.4). I explicitly locked my RoR versions to use what I had in Windows and then ran the migration - still the same error msg. Has anyone else encountered this before?

In the olden days migrations inherited straight from ActiveRecord::Migration. As the error message says, you now need to inherit from a version specific class (ActiveRecord::Migration[4.2], ActiveRecord::Migration[5.1]), depending on which version of Rails you were using when you wrote the migration. This makes it much easier for the rails team to introduce new behaviour to migrations in the future without breaking existing migrations. If it’s a really old migration (ie it is already “included” in the schema.rb or database dumps you use) you might find it easier just to delete the old migrations rather than updating them all.

As an aside you are running rails 5.1.6, ie neither of the versions you mention, so perhaps there is something about that you haven’t understood. The version your app uses should be specified in your Gemfile, (and then with the fully resolved dependencies in Gemfile.lock) so moving to a new machine shouldn’t produce problems based on gem versions - bundler will install the same version of all the gems.

Fred

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3706fdf3-aaf5-454c-84b1-1f98ce8eb914%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.