My migrations were working fine until today. I dropped and re-created the database.But, when I go to apply my migrations, rake migrate aborts with this error. You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.first Any idea what might be wrong? The migrations look right. It''s talking to the database ( I can see the new schema_info table). I''m stumped on this one. -- Best Regards, -Larry "Work, work, work...there is no satisfactory alternative." --- E.Taft Benson -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060805/16903242/attachment.html
On Sat, 2006-08-05 at 08:55 -0700, Larry Kelly wrote:> My migrations were working fine until today. I dropped and re-created > the database.But, when I go to apply my migrations, rake migrate > aborts with this error. > > You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occured while evaluating nil.first > > Any idea what might be wrong? The migrations look right. It''s talking > to the database ( I can see the new schema_info table). I''m stumped on > this one.---- add ''--trace'' to the migrate command which should provide some meaningful information as to which line in your migration file is breaking/causing this Craig
Here is the trace output. But, I''m still not sure where I should be looking for the errors. -Larry ** Invoke migrate (first_time) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.first /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/migration.rb:3 57:in `migration_files'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/connection_ada pters/mysql_adapter.rb:189:in `sort_by'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/migration.rb:3 56:in `migration_files'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/migration.rb:3 39:in `migration_classes'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/migration.rb:3 27:in `migrate'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/migration.rb:2 94:in `up'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/migration.rb:2 85:in `migrate'' /usr/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/tasks/databases.rake:4 /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in `invoke'' /usr/lib/ruby/1.8/thread.rb:135:in `synchronize'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:364:in `invoke_prerequisites'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:999:in `each'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:363:in `invoke_prerequisites'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:356:in `invoke'' /usr/lib/ruby/1.8/thread.rb:135:in `synchronize'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7 /usr/bin/rake:18 On 8/5/06, Craig White <craigwhite@azapple.com> wrote:> > On Sat, 2006-08-05 at 08:55 -0700, Larry Kelly wrote: > > My migrations were working fine until today. I dropped and re-created > > the database.But, when I go to apply my migrations, rake migrate > > aborts with this error. > > > > You have a nil object when you didn''t expect it! > > You might have expected an instance of Array. > > The error occured while evaluating nil.first > > > > Any idea what might be wrong? The migrations look right. It''s talking > > to the database ( I can see the new schema_info table). I''m stumped on > > this one. > ---- > add ''--trace'' to the migrate command which should provide some > meaningful information as to which line in your migration file is > breaking/causing this > > Craig > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Best Regards, -Larry "Work, work, work...there is no satisfactory alternative." --- E.Taft Benson -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060805/98777bb8/attachment.html
Larry Kelly <larry@...> writes:> > > Here is the trace output. But, I''m still not sure where I should be lookingfor the errors. -Larry** Invoke migrate (first_time)** Invoke db:migrate (first_time)** Invoke environment (first_time)** Execute environment> ** Execute db:migraterake aborted!You have a nil object when you didn''t expectit!You might have expected an instance of Array.The error occured while evaluating nil.first/usr/lib/ruby/gems/1.8/gems/activerecord-> 1.14.3/lib/active_record/migration.rb:3 57:in `migration_files''Here are the relevant lines from migration.rb: 355 def migration_files 356 files = Dir["#{@migrations_path}/[0-9]*_*.rb"].sort_by do |f| 357 migration_version_and_name(f).first.to_i 358 end 359 down? ? files.reverse : files 360 end 361 362 def migration_class(migration_name) 363 migration_name.camelize.constantize 364 end 365 366 def migration_version_and_name(migration_file) 367 return *migration_file.scan(/([0-9]+)_([_a-z0-9]*).rb/).first 368 end Line 357 is the problem line. So somehow when it is scanning your /db/migrate directory for relevant files, there is something in there that is not in the typical form of migration naming 001_my_migration.rb. Try clearing out any non-migration files from db/migrate and try again. Good luck, -damon http://damonclinkscales.com/
Thanks Damon, I moved all the migrations out, re-created the db, and applied the migrations one by one. In the process, I discovered that some old svn changes had gotten mixed in with my migrations. Once, I cleared that up. the migrations ran as expected. -Larry On 8/5/06, Damon Clinkscales <scales@pobox.com> wrote:> > Larry Kelly <larry@...> writes: > > > > > > > Here is the trace output. But, I''m still not sure where I should be > looking > for the errors. -Larry** Invoke migrate (first_time)** Invoke db:migrate > (first_time)** Invoke environment (first_time)** Execute environment > > ** Execute db:migraterake aborted!You have a nil object when you didn''t > expect > it!You might have expected an instance of Array.The error occured while > evaluating nil.first/usr/lib/ruby/gems/1.8/gems/activerecord- > > 1.14.3/lib/active_record/migration.rb:3 57:in `migration_files'' > > Here are the relevant lines from migration.rb: > > 355 def migration_files > 356 files = Dir["#{@migrations_path}/[0-9]*_*.rb"].sort_by do |f| > 357 migration_version_and_name(f).first.to_i > 358 end > 359 down? ? files.reverse : files > 360 end > 361 > 362 def migration_class(migration_name) > 363 migration_name.camelize.constantize > 364 end > 365 > 366 def migration_version_and_name(migration_file) > 367 return *migration_file.scan(/([0-9]+)_([_a-z0-9]*).rb/).first > 368 end > > Line 357 is the problem line. So somehow when it is scanning your > /db/migrate > directory for relevant files, there is something in there that is not in > the > typical form of migration naming 001_my_migration.rb. Try clearing out > any > non-migration files from db/migrate and try again. > > Good luck, > -damon > http://damonclinkscales.com/ > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Best Regards, -Larry "Work, work, work...there is no satisfactory alternative." --- E.Taft Benson -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060806/b2ee40c7/attachment.html
Larry Kelly wrote:> Thanks Damon, > > I moved all the migrations out, re-created the db, and applied the > migrations one by one. In the process, I discovered that some old svn > changes had gotten mixed in with my migrations. Once, I cleared that > up. > the migrations ran as expected. > -LarryMost excellent. -damon http://damonclinkscales.com/ -- Posted via http://www.ruby-forum.com/.