Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

Comments

@jarl-dk
Copy link

jarl-dk commented Jun 4, 2012

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
Copy link
Contributor

kennyj commented Jun 4, 2012

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
Copy link
Member

Yes, It was fixed on master. Closing now

@firedev
Copy link
Contributor

firedev commented Jan 5, 2013

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
Projects
None yet
Development

No branches or pull requests

4 participants