remove_index not working with named index in sqlite #1624

clacke opened this Issue Jun 10, 2011 · 3 comments


None yet
2 participants

clacke commented Jun 10, 2011

  • rails 3.0.1
  • sqlite3-ruby 1.3.2
  • fedora 14
  • ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]
  • migration run in development environment, using sqlite

all gems handled through bundler

I have written a migration that simply adds an index to a table:

    class AddIndexBA < ActiveRecord::Migration
      def self.up
        add_index :b, :a_id, :name => :b_a

      def self.down
        remove_index :b, :b_a

$ rake db:migrate
$ rake db:rollback

Expected outcome:
db/schema.rb (and the database) unchanged

Actual outcome:
db/schema.rb claims the index is there, and indeed it is there in the database

Migration and rollback are considered successful, the migration is listed as down by db:migrate:status after the rollback.

clacke commented Jun 10, 2011

The issue does not occur when not providing an explicit name for the index.


raviolicode commented Jun 17, 2011

The problem is that remove_index :table_name, :b_a will try to find the index named index_b_on_b_a, instead of b_a as you expect.

I requested to update the remove_index related documentation in docrails to reflect the current code behavior.

As a side note, removing the index will just log a warning on 3.0.1, though on master the rollback migration fails as expected.

clacke commented Jun 18, 2011

Great, thanks!

@clacke clacke closed this Jun 18, 2011

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