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

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

4 participants

@jarl-dk

Hi.

This is a repeat of an old issue: https://rails.lighthouseapp.com/projects/8994/tickets/4101
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
end

However when I use

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

Things work fine.

This has been reproduced on both PostgreSQL and MySQL adapter. Please
see
http://groups.google.com/group/rubyonrails-talk/msg/e5b9a1fad6ccf79c
for the discussion and confirmation.

Jarl

@kennyj

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!
end

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 ;-)
end

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

@rafaelfranca
Ruby on Rails member

Yes, It was fixed on master. Closing now

@firedev

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