Nomethoderror: Undefined Method '[]' for #<Activerecord::Migration:0X000000033Fedc0>

NoMethodError: undefined method `[]' for #ActiveRecord::Migration:0x000000033fedc0

It seems you are using rails 4.2.

and versioned migration worked in rails 5 only

just remove [5.0] from your migration and it will work fine.

like:

class UpdateUsers < ActiveRecord::Migration
def change
add_column(:users, :provider, :string, limit: 50, null: false, default: '')
add_column(:users, :uid, :string, limit: 500, null: false, default: '')
end
end

NoMethodError: undefined method `needs_migration?' for ActiveRecord::Migrator:Class

change your code to

if ActiveRecord::Base.connection.migration_context.needs_migration?
raise 'Migrations are pending. Run `rake db:migrate` to resolve the issue.'
end

Rails NoMethodError: undefined method `name' for #RecipeType:0x000055cd000b18a0:String

You seemed to have added the recipe_type reference to the wrong table. Your last migration should probably have been

add_reference :recipes, :recipe_type, foreign_key: true

because as it is, you have added the reference_type reference to ReferenceType.

Why does my migration cause NoMethodError: undefined method `jsonb' for #ActiveRecord::ConnectionAdapters::MySQL::TableDefinition?

It looks like you are trying to do this with a sqlite database in your local system, and sqlite does not have json support, try changing your database to either mysql, postgres or a database system that has json support.

Rails NoMethodError: undefined method `name' for #RecipeType:0x000055cd000b18a0:String

You seemed to have added the recipe_type reference to the wrong table. Your last migration should probably have been

add_reference :recipes, :recipe_type, foreign_key: true

because as it is, you have added the reference_type reference to ReferenceType.



Related Topics



Leave a reply



Submit