Drop index

Hello

In my migration, I created index as follows:
def self.up
add_index :users, :facebook_id
add_index :references, [:referencing_user_id, :created_at]

and

def self.down
remove_index :users, :facebook_id
remove_index :references, [:referencing_user_id, :created_at]

working fine when creating …

== 7 AddIndexes: migrating

– add_index(:users, :facebook_id)
-> 0.0067s
– add_index(:references, [:referencing_user_id, :created_at])
-> 0.0063s

but when reverting , I get an error :

== 7 AddIndexes: reverting

– remove_index(:users, :facebook_id)
-> 0.0485s
– remove_index(:references, :referencing_user_id)
rake aborted!
Mysql::Error: #42000You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near ‘references’ at line 1: DROP INDEX
index_references_on_referencing_user_id ON references

the generated sql is :
DROP INDEX index_references_on_referencing_user_id_and_created_at
ON REFERENCES
which doesn’t work at all !!! 42000 is a syntax error !!!

why, the index has been created, … how can I delete it ? is it a
rails’ bug ? (using 2.0)

thanks

On 13 Apr 2008, at 10:17, Erwin wrote:

def self.down
remove_index :users, :facebook_id
remove_index :references, [:referencing_user_id, :created_at]

The bad thing here seems to be that rails should be quoting that table
name. The easiest way would probably to write out the sql statement
yourself.

Fred