This project is archived and is in readonly mode.
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 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 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 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
honoredtable_name_prefix
. That is, the task (a) created tables in thedevelopment
environment with the prefix and (b) created aschema.rb
file with the prefixes. Then, when I ranrake db:test:load
, it, too, honored the prefix, causing double prefixes.If
db:test:load
is going to honortable_name_prefix
(which is should, since otherwise it gets theunique_schema_migrations
index wrong),db:migrate
should NOT put prefixes intoschema.rb
.
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>