This project is archived and is in readonly mode.

#1568 ✓duplicate
Gaius Centus Novus

schema_statements#initialize_schema_migrations_table does not respect config.active_record.table_name_prefix

Reported by Gaius Centus Novus | December 13th, 2008 @ 05:35 PM | in 2.x

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.

Comments and changes to this ticket

  • Gaius Centus Novus

    Gaius Centus Novus December 13th, 2008 @ 05:44 PM

    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.

  • Tim Peters

    Tim Peters December 16th, 2008 @ 11:34 PM

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

  • Gaius Centus Novus

    Gaius Centus Novus December 20th, 2008 @ 05:10 PM

    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.

  • Pratik

    Pratik January 18th, 2009 @ 07:02 AM

    • State changed from “new” to “duplicate”

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

Pages