Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Rails3 RC - Schema.rb file does not contain all indexes created with migration in postgresql (postgres)

#5314

Steps to reproduce:

a) run given migrations

class CreateTable < ActiveRecord::Migration
  def self.up
    create_table :business_object_type_functions do |t|
      t.string :name
      t.string :function_id
      t.string :business_object_type_id

    end
  end
end

class AddMultiColumnIndex < ActiveRecord::Migration

  def self.up
    add_index(:business_object_type_functions, :business_object_type_id)
    add_index(:business_object_type_functions, [:function_id, :business_object_type_id], :unique => true)
  end

end

b) watch the schema.rb file. It looks like this:

ActiveRecord::Schema.define(:version => 20100806074816) do

  create_table "business_object_type_functions", :force => true do |t|
    t.string   "name"
    t.string   "function_id"
    t.string   "business_object_type_id"
  end

  add_index "business_object_type_functions", ["business_object_type_id"], :name => "index_business_object_type_functions_on_business_object_type_id"

end

As you can see the schema.rb is missing the second multicolumn index that was added in the migration. I guess this might happen because of its long name. But that's just my guess.

Reported by Robert Pankowecki · August 6th, 2010 @ 09:10 AM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. codemanki
    codemanki

    Robert, yes, this is because there is a limit of 64 chars per index name - database_limits.rb:21

    And here is a exception which must be raise, but i think in migrations it doesn't - schema_statements.rb:341

    October 10th, 2010 @ 11:41 AM

  2. codemanki
    codemanki

    This ticket can be closed, i suppose. I tested these migrations and got

    /Users/codemanki/projects/misc/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:341:in
    add_index': Index name 'index_business_object_type_functions_on_function_id_and_business_object_type_id' on table 'business_object_type_functions' is too long; the limit is 64 characters (ArgumentError) </code>

    October 10th, 2010 @ 11:51 AM

  3. David Trasbo
    David Trasbo
    • State changed from new to invalid
    • Importance changed from to Low

    October 10th, 2010 @ 02:16 PM

  4. Robert Pankowecki
    Robert Pankowecki

    Which rails version raises the exception during migration. What database did you use during the test ?

    October 10th, 2010 @ 02:32 PM