This project is archived and is in readonly mode.

#2402 ✓resolved
James B. Byrne

AR::Migrations not quoting index names?

Reported by James B. Byrne | April 2nd, 2009 @ 11:15 PM | in 2.x

Rails 2.3.2 gem

PostgreSQL 8.3.7

Situation:

Given a migration containing an index name with mixed case f.e. (idxU_name)

And given the DB adapter is postgresql

When rake db:migrate is run

Then the index idxU_name is created

When rake db:migrate VERSION=0 is run

Then the mirgration attempts to remove an index named idxu_name, which fails.

#db/migrate/x_create_sessions.rb
  def self.up
    ...
    add_index     :sessions, :updated_at,   
                    :name   => :idxR_sessions_updated_at,
                    :unique => false
  end

  def self.down
    remove_index  :sessions,  :name   => :idxR_sessions_updated_at
...
# rake db:migrate VERSION=0

==  CreateSessions: reverting =================================================
-- remove_index(:sessions, {:name=>:idxR_sessions_updated_at})
rake aborted!
An error has occurred, this and all later migrations canceled:

PGError: ERROR:  index "idxr_sessions_updated_at" does not exist
: DROP INDEX idxR_sessions_updated_at

Note the lack of quotes around the DROP argument. PostgreSQl will lowercase all arguments unless they are enclosed in quotes.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Referenced by

Pages