# Drop index

**URL:** <https://www.ruby-forum.com/t/drop-index/134642>\
**Category:** Rails\
**Created:** [April 13, 2008, 11:18am UTC](https://www.ruby-forum.com/t/drop-index/134642 "2008-04-13T11:18:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e57/32.png) [@Erwin](https://www.ruby-forum.com/u/Erwin)\
**Post date:** [April 13, 2008, 11:18am UTC](https://www.ruby-forum.com/t/drop-index/134642/1 "2008-04-13T11:18:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Erwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e57/32.png) [@Erwin](https://www.ruby-forum.com/u/Erwin)\
**Post date:** [April 13, 2008, 12:58pm UTC](https://www.ruby-forum.com/t/drop-index/134642/2 "2008-04-13T12:58:41Z")

</div>

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
