Postgresql Migration Failure on 4th migration (attachment_fu). A migration fails mysteriously. The console says: rake aborted! uninitialized constant AttachmentImages The log says: SQL (0.000000) PGError: ERROR: relation "schema_info" already exists : CREATE TABLE schema_info (version integer) Of course it exists, it''s up to 3. The database is not modified. Rails 1.2.4, ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] The failing migration looks okay to me: def self.up add_column :images, :parent_id, :integer add_column :images, :content_type, :string add_column :images, :filename, :string add_column :images, :thumbnail, :string add_column :images, :size, :integer add_index :images, :artist_id end fredistic --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Nov-06 14:35 UTC
Re: Why is this migration trying to re-create schema_info?
On 6 Nov 2007, at 12:59, fredistic wrote:> > Postgresql Migration Failure on 4th migration (attachment_fu). > A migration fails mysteriously. > > The console says: > rake aborted! > uninitialized constant AttachmentImagesIs there a stack trace to go with that ? Fred> > > The log says: > SQL (0.000000) PGError: ERROR: relation "schema_info" already > exists > : CREATE TABLE schema_info (version integer) > > Of course it exists, it''s up to 3. > > The database is not modified. > > Rails 1.2.4, > ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] > > The failing migration looks okay to me: > def self.up > add_column :images, :parent_id, :integer > add_column :images, :content_type, :string > add_column :images, :filename, :string > add_column :images, :thumbnail, :string > add_column :images, :size, :integer > > add_index :images, :artist_id > end > > > fredistic > > > >--~--~---------~--~----~------------~-------~--~----~ 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-Nov-06 17:06 UTC
Re: Why is this migration trying to re-create schema_info?
On 11/6/07, fredistic <fredistic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Postgresql Migration Failure on 4th migration (attachment_fu). > A migration fails mysteriously. > > The console says: > rake aborted! > uninitialized constant AttachmentImages > > The log says: > SQL (0.000000) PGError: ERROR: relation "schema_info" already > exists > : CREATE TABLE schema_info (version integer) > > Of course it exists, it''s up to 3.Those are two different problems. The second is unrelated to the first and can be ignored. AR just blindly tries to create the schema_info in every migration; it ignores the "already exists" problem. You need to investigate the AttachmentImages problem. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
James Byrne
2007-Nov-06 17:17 UTC
Re: Why is this migration trying to re-create schema_info?
fredistic wrote:> Postgresql Migration Failure on 4th migration (attachment_fu). > A migration fails mysteriously. > > The console says: > rake aborted! > uninitialized constant AttachmentImages > > The log says: > SQL (0.000000) PGError: ERROR: relation "schema_info" already > exists > : CREATE TABLE schema_info (version integer) > > Of course it exists, it''s up to 3. > > The database is not modified. > > Rails 1.2.4, > ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] > > The failing migration looks okay to me: > def self.up > add_column :images, :parent_id, :integer > add_column :images, :content_type, :string > add_column :images, :filename, :string > add_column :images, :thumbnail, :string > add_column :images, :size, :integer > > add_index :images, :artist_id > end > >The schema_info error indicates that something may be borked in your migration naming. You have confirmed that you do not have two migrations whose file names differ only by the number prefix, right? If that is not the problem then what does your class attachment_image(s???) < ActiveRecord::Base in app/models/attachment_image(s????).rb say? If that is consistent with your class name then what does your class attachment_image(s???) < ActiveRecord::Migration in the db/migrate/004_attachment_image(s???).rb migration file say? You may have a problem with the naming of your classes if in truth you use plural in some places and singular in others. Regards, -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
fredistic
2007-Nov-06 18:55 UTC
Re: Why is this migration trying to re-create schema_info?
F.C. asked for a stack trace. Changing the file name changes the name of the uninitialized constant that triggers the error, matching it. Here it is called 004_imaginary.rb. So the "uninitialized constant'' it complains about is ''Imaginary''. I''ve tried other names and the error message follows the file name. I can use rake db:migrate VERSION=2 and 3 to go back and forth without a problem. Putting in ''VERSION=4'' results in identical error messages, of course. Schema_info in the database is 3.>dir db\migrateDirectory of C:\InstantRails\rails_apps\g1\db\migrate 11/06/2007 03:42 PM <DIR> . 11/06/2007 03:42 PM <DIR> .. 10/19/2007 03:44 PM 474 001_create_images.rb 10/19/2007 03:44 PM 612 002_create_users.rb 10/19/2007 03:44 PM 561 003_more_user.rb 11/06/2007 03:39 PM 767 004_imaginary.rb 4 File(s) 2,414 bytes 2 Dir(s) 18,688,790,528 bytes free>rake --trace db:migrate(in C:/InstantRails/rails_apps/g1) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! uninitialized constant Imaginary C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.3/lib/ active_support/dependencies.rb:266:in `load_missing_constant'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.3/lib/ active_support/dependencies.rb:452:in `const_missing'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.3/lib/ active_support/dependencies.rb:464:in `const_missing'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.3/lib/ active_support/inflector.rb:250:in `constantize'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.3/lib/ active_support/core_ext/string/inflections.rb:148:in `constantize'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.4/lib/ active_record/migration.rb:366:in `migration_class'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.4/lib/ active_record/migration.rb:346:in `migration_classes'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.4/lib/ active_record/connection_adapters/abstract_adapter.rb:128:in `inject'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.4/lib/ active_record/migration.rb:342:in `each'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.4/lib/ active_record/migration.rb:342:in `inject'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.4/lib/ active_record/migration.rb:342:in `migration_classes'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.4/lib/ active_record/migration.rb:330:in `migrate'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.4/lib/ active_record/migration.rb:297:in `up'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.4/lib/ active_record/migration.rb:288:in `migrate'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.4/lib/tasks/ databases.rake:4 C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb: 399:in `call'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb: 399:in `execute'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb: 399:in `each'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb: 399:in `execute'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb: 369:in `invoke'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb: 362:in `synchronize'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb: 362:in `invoke'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb: 1935:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb: 1935:in `each'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb: 1935:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rake-0.7.2/bin/rake:7 C:/InstantRails/ruby/bin/rake.bat:20:in `load'' C:/InstantRails/ruby/bin/rake.bat:20 fredistic --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
fredistic
2007-Nov-06 18:58 UTC
Re: Why is this migration trying to re-create schema_info? PROBLEM SOLVED
I changed the name of the class to match the name of the .rb file and and it just worked. I did not understand they had to be the same. Perhaps I once knew and forgot? Thanks for all the help... On Nov 6, 7:17 pm, James Byrne <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> fredistic wrote: > > Postgresql Migration Failure on 4th migration (attachment_fu). > > A migration fails mysteriously...--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
fredistic
2007-Nov-06 19:10 UTC
Re: Why is this migration trying to re-create schema_info? PROBLEM SOLVED
I changed the name of the class to match the name of the .rb file and and it just worked. I did not understand they had to be the same. Perhaps I once knew and forgot? Thanks for all the help... On Nov 6, 7:17 pm, James Byrne <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> fredistic wrote: > > Postgresql Migration Failure on 4th migration (attachment_fu). > > A migration fails mysteriously...--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
James Byrne
2007-Nov-06 20:37 UTC
Re: Why is this migration trying to re-create schema_info? P
fredistic wrote:> I changed the name of the class to match the name of the .rb file and > and it just worked. I did not understand they had to be the same. > Perhaps I once knew and forgot? Thanks for all the help... > > On Nov 6, 7:17 pm, James Byrne <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Convention over configuration. Rails depends upon the contents of its project files having class names consistent with its conventions and maintaining the relationship of the class name to the name of the containing file is one of those conventions. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---