# \[2.2.2\]Migration failing because MySQL has no "each" method?

**URL:** <https://www.ruby-forum.com/t/2-2-2-migration-failing-because-mysql-has-no-each-method/162423>\
**Category:** Rails\
**Created:** [March 9, 2009, 9:12pm UTC](https://www.ruby-forum.com/t/2-2-2-migration-failing-because-mysql-has-no-each-method/162423 "2009-03-09T21:12:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![robkuz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/34f0e0/32.png) [@robkuz](https://www.ruby-forum.com/u/robkuz)\
**Post date:** [March 9, 2009, 9:12pm UTC](https://www.ruby-forum.com/t/2-2-2-migration-failing-because-mysql-has-no-each-method/162423/1 "2009-03-09T21:12:36Z")

</div>

Hey all.

I’m trying to do a simple migration, but the MySQL adapter keeps  
choking. This used to work before, and was just fine before my latest  
OS reformat. I’ve got libmysql.dll in Ruby’s /bin directory, and most  
the other migrations work well. This migration dies on a  
“rename\_column” call.

I’m calling:

> rename\_column :users, :password, :hashed\_password

In the self.up method. The table Users exists and has the field  
“password”. If I manually migrate this event and add the key into the  
database for that, so it will finish my migrations (it’s in the middle  
that it’s failing!) I am told that it isn’t synchronized and it won’t  
finish generating a schema.

I don’t know what to do, what to edit, or even what is broken … and  
I’m deploying this week. This is about to drive me up the wall.

Thank you for any help, tips, or suggestions in advance. I can produce  
the migrations if necessary, but they’re a very simple set of migrations  
and they were working just a month ago. I haven’t changed a thing since  
then (until I revised a template just today) due to a lockdown.

This is my first Rails app an I’m already getting a little discouraged  
at these strange errors.

## My gems:

> actionmailer (2.2.2)  
> actionpack (2.2.2)  
> activerecord (2.2.2)  
> activeresource (2.2.2)  
> activesupport (2.2.2)  
> BlueCloth (1.0.0)  
> capistrano (2.5.5)  
> cgi\_multipart\_eof\_fix (2.5.0)  
> diff-lcs (1.1.2)  
> gem\_plugin (0.2.3)  
> grit (1.0.1)  
> haml (2.0.9, 2.0.8, 2.0.7)  
> highline (1.5.0)  
> maruku (0.5.9)  
> mime-types (1.16, 1.15)  
> mongrel (1.1.5)  
> mysql (2.7.3)  
> net-scp (1.0.2)  
> net-sftp (2.0.2)  
> net-ssh (2.0.11)  
> net-ssh-gateway (1.0.1)  
> polyglot (0.2.5, 0.2.4)  
> pony (0.3)  
> rack (0.9.1)  
> rails (2.2.2)  
> rake (0.8.4, 0.8.3)  
> RedCloth (4.1.9, 4.1.1)  
> rubypants (0.2.0)  
> schacon-git (1.0.7)  
> sequel (2.11.0, 2.10.0)  
> sinatra (0.9.1, 0.9.0.4)  
> syntax (1.0.0)  
> tmail (1.2.3.1)  
> treetop (1.2.4)  
> WikiCreole (0.1.3)

* * *

## rake db:migrate --trace

# \*\* Invoke db:migrate (first\_time) \*\* Invoke environment (first\_time) \*\* Execute environment \*\* Execute db:migrate == RenamePasswordToHashed: migrating

– rename\_column(:users, :password, :hashed\_password)  
rake aborted!  
An error has occurred, all later migrations canceled:

undefined method `each' for #<Mysql:0x4841af8> C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connec tion_adapters/mysql_adapter.rb:440:in`columns’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active\_record/connec  
tion\_adapters/mysql\_adapter.rb:485:in `rename_column' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migrat ion.rb:346:in`send’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active\_record/migrat  
ion.rb:346:in `method_missing' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migrat ion.rb:326:in`say\_with\_time’  
C:/Utils/Ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migrat ion.rb:326:in`say\_with\_time’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active\_record/migrat  
ion.rb:342:in `method_missing' ./db/migrate//20081121194833_rename_password_to_hashed.rb:3:in`up\_without\_bench  
marks’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active\_record/migrat  
ion.rb:280:in `send' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migrat ion.rb:280:in`migrate’  
C:/Utils/Ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migrat ion.rb:280:in`migrate’  
( **DELEGATION** ):2:in ` __send__' ( __DELEGATION__ ):2:in`migrate’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active\_record/migrat  
ion.rb:480:in `migrate' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migrat ion.rb:556:in`call’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active\_record/migrat  
ion.rb:556:in `ddl_transaction' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migrat ion.rb:479:in`migrate’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active\_record/migrat  
ion.rb:466:in `each' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migrat ion.rb:466:in`migrate’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active\_record/migrat  
ion.rb:394:in `up' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migrat ion.rb:377:in`migrate’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/databases.rake:111  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in  
`call' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in`execute’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in  
`each' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in`execute’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in  
`invoke_with_ call_chain' C:/Utils/Ruby/lib/ruby/1.8/monitor.rb:242:in`synchronize’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in  
`invoke_with_ call_chain' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in`invoke’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in  
`invoke_task ' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in`top\_level’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in  
`each' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in`top\_level’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in  
`standard_ex ception_handling' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in`top\_level’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in  
`run' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in`standard\_ex  
ception\_handling’  
C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in  
`run' C:/Utils/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:31 C:/Utils/Ruby/bin/rake:19:in`load’  
C:/Utils/Ruby/bin/rake:19

---

<div class="post-metadata">

**Author:** ![robkuz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/34f0e0/32.png) [@robkuz](https://www.ruby-forum.com/u/robkuz)\
**Post date:** [March 9, 2009, 9:46pm UTC](https://www.ruby-forum.com/t/2-2-2-migration-failing-because-mysql-has-no-each-method/162423/2 "2009-03-09T21:46:23Z")

</div>

I forgot to mention that because of the “undefined method `each’ for  
#Mysql:0x4841af8” exception I cannot even use the command, “rake  
db:schema:load” because it fails on the first table with this command.  
I suspect there’s a flaw in the version of my MySQL gem, but I’ll be  
darned if I know what version to revert to.
