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.

schema_statements#initialize_schema_migrations_table does not respect config.active_record.table_name_prefix

#1568

In my /config/environment.rb, I have


config.active_record.table_name_prefix = 'ts_'

I'm getting an error when running rake test:units:


SQLite3::SQLException: index unique_schema_migrations already exists: CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")

Looking at the database, I see both a ts_schema_migrations table and a schema_migrations table. This worries me because I might be stepping on the schema_migrations of other Rails apps that use the same database.

Reported by Gaius Centus Novus · December 13th, 2008 @ 05:35 PM

State: duplicate
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Gaius Centus Novus
    Gaius Centus Novus

    On second thought, I'm not sure it has anything to do with config.active_record.table_name_prefix. I had a custom rake task that was mucking with the table_name_prefix. Removing the task causes the error message to change to

    
    SQLite3::SQLException: index unique_schema_migrations already exists: CREATE UNIQUE INDEX "unique_schema_migrations" ON "ts_schema_migrations" ("version")
    

    That is, there's simply something wrong with trying to re-create the schema migrations index.

    December 13th, 2008 @ 05:44 PM

  2. Tim Peters
    Tim Peters

    Possibly related to #1543 index "unique_schema_migrations" should use table prefix/suffix (which includes a patch); that unique_schema_migrations index should use the table prefix in it's name.

    December 16th, 2008 @ 11:34 PM

  3. Gaius Centus Novus
    Gaius Centus Novus

    Digging a little further...

    The reason I added the custom rake task to muck with table_name_prefix is that rake db:migrate honored table_name_prefix. That is, the task (a) created tables in the development environment with the prefix and (b) created a schema.rb file with the prefixes. Then, when I ran rake db:test:load, it, too, honored the prefix, causing double prefixes.

    If db:test:load is going to honor table_name_prefix (which is should, since otherwise it gets the unique_schema_migrations index wrong), db:migrate should NOT put prefixes into schema.rb.

    December 20th, 2008 @ 05:10 PM

  4. Pratik