ActiveRecord::ConnectionAdapters::Table#index does not generat indexes #6620

jarl-dk opened this Issue Jun 4, 2012 · 3 comments

4 participants



This is a repeat of an old issue:
The problem still exists, though an error message has been introduced such as

undefined method `index' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x00000004d819c8>

I willl repeat the original report here:

When using the following syntax for creating indexes in a migration, no indexes are created:

create_table :properties do |t|
  t.string :namespace
  t.string :name
  t.string :value

  t.index [:namespace, :name], :unique => true

However when I use

create_table :properties do |t|
  t.string :namespace
  t.string :name
  t.string :value
add_index :properties, [:namespace, :name], :unique => true

Things work fine.

This has been reproduced on both PostgreSQL and MySQL adapter. Please
for the discussion and confirmation.



In 3-2-stable, TableDefinition class has not index method. But in master, this has index method ca0af82.

Table class has index method, thus when we execute change_table method, the following code is work fine.

change_table :products do |t|
  t.string :part_number
  t.index :part_number ★ work fine!

but when we execute create_table, we can't call index method.

create_table :products do |t|
  t.string :part_number
  t.index :part_number ★ ng ;-)

I think this behavior is specification in the 3-2-stable.

Ruby on Rails member

Yes, It was fixed on master. Closing now


Rails 3.2.10 - Undefined methodindex' for #<ActiveRecord::ConnectionAdapters::TableDefinition`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment