Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

AR::Migrations not quoting index names?

#2402

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.

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

State: resolved
Milestone: 2.x
Assigned to: Tarmo Tänav Tarmo Tänav
Importance: none

Activity

  1. Jeff
    Jeff
    • Tag changed from active_record, bug, defect, migrations, postgresql to active_record, bug, defect, migrations, patch, postgresql

    this should cover it

    April 5th, 2009 @ 09:43 PM

  2. Max Lapshin
    Max Lapshin
    • Tag changed from active_record, bug, defect, migrations, patch, postgresql to 2.3.2, active_record, bug, defect, index, migrations, patch, postgresql, test
    • Assigned user set to Tarmo Tänav

    I've added failing test and fixed remove_index in Postgres adapter. Previous patch didn't handled issue, when multischema environment, but I've used my previous patches and fixed this issue.

    April 20th, 2009 @ 05:10 PM

  3. Repository
    Repository
    • State changed from new to resolved

    (from [cdcd638c2f27ebf98ba7aa59512547f58a5e0c61]) Fixed wrong quoting of index names in postgres [#2402 AR::Migrations not quoting index names? state:resolved]

    Signed-off-by: Tarmo Tänav tarmo@itech.ee http://github.com/rails/rails/co...

    April 21st, 2009 @ 11:51 AM

  4. Repository
    Repository

    (from [de4cc53f7428090600b9e31ee39cf8c4c0df811e]) Fixed wrong quoting of index names in postgres [#2402 AR::Migrations not quoting index names? state:resolved]

    Signed-off-by: Tarmo Tänav tarmo@itech.ee http://github.com/rails/rails/co...

    April 21st, 2009 @ 11:52 AM