This project is archived and is in readonly mode.

#5314 ✓invalid
Robert Pankowecki

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

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

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


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)


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"

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


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.

Comments and changes to this ticket

  • codemanki

    codemanki October 10th, 2010 @ 11:41 AM

    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

  • codemanki

    codemanki October 10th, 2010 @ 11:51 AM

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

    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>

  • David Trasbo

    David Trasbo October 10th, 2010 @ 02:16 PM

    • State changed from “new” to “invalid”
    • Importance changed from “” to “Low”
  • Robert Pankowecki

    Robert Pankowecki October 10th, 2010 @ 02:32 PM

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

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>