Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails5 Directly inheriting from from ActiveRecord::Migration is not supported. Sorcery Gem

I am trying to migrate a Rails 3 app. I installed Rails v 5.1.5 using RVM. When trying db:migrate, I get the following.

rake aborted! StandardError: An error has occurred, all later migrations canceled:

Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

class SorceryCore < ActiveRecord::Migration[4.2]

Here is the Class Definition for Sorcerycore:

class SorceryCore < <%= migration_class_name %>        


  def change
    create_table :<%= model_class_name.tableize %> do |t|
      t.string :email,            :null => false
      t.string :crypted_password
      t.string :salt

      t.timestamps                :null => false
    end

    add_index :<%= model_class_name.tableize %>, :email, unique: true
  end
end
like image 755
uberdave Avatar asked Feb 15 '18 20:02

uberdave


2 Answers

You have to specify the version in brackets like it says. Have you added any migrations since upgrading?

Example change from:

class SorceryCore < ActiveRecord::Migration

to

class SorceryCore < ActiveRecord::Migration[5.1]

You can add the version to all migrations by running this from your Rails root directory:

grep -rl ActiveRecord::Migration$ db | xargs sed -i "" "s/ActiveRecord::Migration/ActiveRecord::Migration[5.1]/g"
like image 161
Trinculo Avatar answered Oct 22 '22 02:10

Trinculo


Add your migration version at last Like

class SorceryCore < ActiveRecord::Migration[5.1]

so here [5.1] is your version so add version

if you don't know the version please check your previous migration, may you find there...

like image 35
CHAVDA MEET Avatar answered Oct 22 '22 01:10

CHAVDA MEET