Skip to content

migration fail in rails 5.1.z  #111

Description

@buncis
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 ActsAsCommentableWithThreadingMigration < ActiveRecord::Migration[4.2]
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/migration.rb:525:in `inherited'
/home/user/lazy-api/db/migrate/20170808131454_acts_as_commentable_with_threading_migration.rb:1:in `<top (required)>'
/home/user/.rvm/gems/ruby-2.2.6/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `require'
/home/user/.rvm/gems/ruby-2.2.6/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `block in require'
/home/user/.rvm/gems/ruby-2.2.6/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:258:in `load_dependency'
/home/user/.rvm/gems/ruby-2.2.6/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `require'
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/migration.rb:962:in `load_migration'
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/migration.rb:958:in `migration'
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/migration.rb:953:in `disable_ddl_transaction'
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/migration.rb:1305:in `use_transaction?'
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/migration.rb:1297:in `ddl_transaction'
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/migration.rb:1229:in `execute_migration_in_transaction'
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/migration.rb:1201:in `block in migrate_without_lock'
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/migration.rb:1200:in `each'
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/migration.rb:1200:in `migrate_without_lock'
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/migration.rb:1150:in `migrate'
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/migration.rb:1007:in `up'
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/migration.rb:985:in `migrate'
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
/home/user/.rvm/gems/ruby-2.2.6/gems/activerecord-5.1.2/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/home/user/.rvm/gems/ruby-2.2.6/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/home/user/.rvm/gems/ruby-2.2.6/bin/ruby_executable_hooks:15:in `eval'
/home/user/.rvm/gems/ruby-2.2.6/bin/ruby_executable_hooks:15:in `<main>'

I need to add the migration version [5.1] to fix this

class ActsAsCommentableWithThreadingMigration < ActiveRecord::Migration[5.1]
  def self.up
    create_table :comments, :force => true do |t|
      t.integer :commentable_id
      t.string :commentable_type
      t.string :title
      t.text :body
      t.string :subject
      t.integer :user_id, :null => false
      t.integer :parent_id, :lft, :rgt
      t.timestamps
    end

    add_index :comments, :user_id
    add_index :comments, [:commentable_id, :commentable_type]
  end

  def self.down
    drop_table :comments
  end
end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions