Hi Tim, It definitely looks like a historical problem (though very interesting, as it might happen to others in the future).
I just tried in a Postgresql app to create a similar index, and this is what happened: ---------- Up Migration ---------- create_table :other_related_instruments do |t| t.datetime :created_at t.datetime :updated_at end create_table :document_other_related_instruments do |t| t.string :name t.datetime :created_at t.datetime :updated_at t.integer :other_related_instrument_id end add_index :document_other_related_instruments, [:other_related_instrument_id], :name => 'index_document_other_related_instruments_on_other_related_instr' ---------------------------------- The index was created with 63 characteres instead of your 64 characters, and everything worked. I would suggest editing your schema.rb and fixint it manually, as it can be safely said the error was provoked when switching databases. Warm regards, Ignacio El 27/01/14 04:12, Tim Griffin escribió: > I should mention that this error is arising from my schema.rb when I try > to do a /rake db:schema:load/ to migrate to PostgreSQL: > > create_table "document_other_related_instruments", :force => true do |t| > t.datetime "created_at" > t.datetime "updated_at" > t.integer "document_id" > t.integer "other_related_instrument_id" > end > > add_index "document_other_related_instruments", ["document_id"], :name > => "index_document_other_related_instruments_on_document_id" > add_index "document_other_related_instruments", > ["other_related_instrument_id"], :name => > "*index_document_other_related_instruments_on_other_related_instru*" > > And, the name here is quite definitely 64 characters. > > But, now I'm not sure if this is an /historical/ problem - an index > created in my MySQL database some time ago that has persisted as valid > for MySQL (being max of 64 characters long), but invalid for PostgreSQL > (which can't exceed 63 characters)? > > I see here > <http://postgresql.1045698.n5.nabble.com/NAME-maximum-length-in-bytes-td5695932.html>, > that PostgreSQL docs mention for the max length of an index name: > > /Its length is currently defined as 64 bytes (63 usable characters > plus terminator)./ > > My obvious work-around is to change the name in my schema.rb file, so > perhaps I'm just chasing my tail. > > Tim > > > > > > On Sunday, January 26, 2014 3:32:38 PM UTC-5, Tim Griffin wrote: > > Hi Ignacio; > > I have *document.rb:* > class Document < ActiveRecord::Base > hobo_model > ... > # Other instruments referenced by this document > has_many :document_other_related_instruments, :accessible => true > has_many :other_related_instruments, :class_name => > "Instrument", :through => :document_other_related_instruments > end > > and *document_other_related_instrument.rb* > class DocumentOtherRelatedInstrument < ActiveRecord::Base > > hobo_model > ... > belongs_to :document > belongs_to :other_related_instrument, :class_name => "Instrument" > ... > end > > Gives me: > > -- add_index("document_other_related_instruments", > ["other_related_instrument_id"], > > {:name=>"index_document_other_related_instruments_on_other_related_instru"}) > rake aborted! Index name > 'index_document_other_related_instruments_on_other_related_instru' > on table 'document_other_related_instruments' is too long; the limit > is 63 characters > > > > Tim > > > -- > You received this message because you are subscribed to the Google > Groups "Hobo Users" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/hobousers. > For more options, visit https://groups.google.com/groups/opt_out. -- Ignacio Huerta Arteche http://www.ihuerta.net Teléfono: 0034 645 70 77 35 Email realizado con software libre -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/hobousers. For more options, visit https://groups.google.com/groups/opt_out.
