Robert Hulme
2007-Sep-11 10:48 UTC
uninitialized constant CreateDb when using rake db:migrate
Does anyone have any idea why I might be getting this error? I''m using sqlite3 with Rails 1.2.3 and ruby 1.8.5 (2006-08-25) [i486-linux] rake db:migrate --trace (in /home/robhu/incremental) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:266:in `load_missing_constant'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in `const_missing'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:464:in `const_missing'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/inflector.rb:250:in `constantize'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/core_ext/string/inflections.rb:148:in `constantize'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/migration.rb:366:in `migration_class'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/migration.rb:346:in `migration_classes'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/sqlite_adapter.rb:352:in `inject'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/migration.rb:342:in `each'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/migration.rb:342:in `inject'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/migration.rb:342:in `migration_classes'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/migration.rb:330:in `migrate'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/migration.rb:297:in `up'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/migration.rb:288:in `migrate'' /usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/tasks/databases.rake:4 /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke'' /usr/lib/ruby/1.8/thread.rb:135:in `synchronize'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in `top_level'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 /usr/bin/rake:16:in `load'' /usr/bin/rake:16 trueman% cat db/migrate/001_create_db.rb class CreateTasks < ActiveRecord::Migration def self.up create_table :tasks do |t| t.column :name, :string end end def self.down drop_table :tasks end end -Rob -- http://www.robhulme.com/ http://robhu.livejournal.com/ Think of how many religions attempt to validate themselves with prophecy. Think of how many people rely on these prophecies, however vague, however unfulfilled, to support or prop up their beliefs. Yet has there ever been a religion with the prophetic accuracy and reliability of science? ... No other human institution comes close. -- Carl Sagan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Robert Hulme
2007-Sep-12 11:07 UTC
Re: uninitialized constant CreateDb when using rake db:migrate
> Does anyone have any idea why I might be getting this error? I''m using > sqlite3 with Rails 1.2.3 and ruby 1.8.5 (2006-08-25) [i486-linux]Aha. The reason was something to do with creating db/migrate/001_foo.rb myself. When I used the generator it worked fine. -Rob -- http://www.robhulme.com/ http://robhu.livejournal.com/ Saying that Java is good because it works on all platforms is like saying anal sex is good because it works on all genders. --Anonymous --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bob Showalter
2007-Sep-12 14:13 UTC
Re: uninitialized constant CreateDb when using rake db:migrate
On 9/11/07, Robert Hulme <rob-7tdvfriZBvFWk0Htik3J/w@public.gmane.org> wrote:> > Does anyone have any idea why I might be getting this error? I''m using > sqlite3 with Rails 1.2.3 and ruby 1.8.5 (2006-08-25) [i486-linux] > > > trueman% cat db/migrate/001_create_db.rb > class CreateTasks < ActiveRecord::MigrationThe migration code looks for a class based on the file name of the migration. So since your migration file is named 001_create_db.rb, it strips off the 001_ part and turns create_db into the class CreateDb and tries to peform CreateDb.up, which can''t be found. So you need to either name the migration file as 001_create_tasks.rb, or rename the class to CreateDb. You found out that the generator keeps things in order for you. If you need a migration to add a table, I suggest you generate a model instead of a migration. The model generator will create a migration for you as it creates the model skeleton. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---