This project is archived and is in readonly mode.
index "unique_schema_migrations" should use table prefix/suffix
Reported by Tim Peters | December 10th, 2008 @ 06:32 AM | in 2.3.10
Create 2 rails apps, both of which share a database schema and use different table name prefixes.
in app1/config/environment.rb: config.active_record_table_name_prefix = 'app1_'
in app2/config/environment.rb: config.active_record_table_name_prefix = 'app2_'
The apps will correctly use the names app1_schema_migrations and app2_schema_migrations to hold migrations. However, both will try to create an index named "unique_schema_migrations" on their table. The second app which does this will get an error.
Attached patch adds any table prefix / suffix to the name of the unique_schema_migrations index.
Comments and changes to this ticket
-
Jordi Bunster December 22nd, 2008 @ 11:07 PM
- Tag changed from bug, migrations to bug, migrations, patch
+1
When I created the index I decided to use the
add_index
method instead of custom SQL, because I assumed it added the correct prefixes. I now see that it doesn't (not when using:name
anyway), just ascreate_table
doesn't either. -
Frederick Cheung December 23rd, 2008 @ 11:04 AM
- State changed from new to incomplete
Looks reasonable to me, could we have a test for this too?
-
Pratik January 18th, 2009 @ 07:03 AM
- Milestone cleared.
- Assigned user set to Frederick Cheung
-
CancelProfileIsBroken August 4th, 2009 @ 06:11 PM
- Tag changed from bug, migrations, patch to bug, bugmash, migrations, patch
-
David Trasbo August 9th, 2009 @ 02:19 PM
+1
Patch applies cleanly to edge and the tests are passing.
-
Elad Meidar August 9th, 2009 @ 03:45 PM
+1 Patch applies cleanly on 2-3-stable as tests pass too.
Is it really necessary for 2 applications to create the same index ? i think it's something the developer and the DBA should decide before, no reason to create 2 unique indexes, can someone please come up with a case example ?
-
Cristi Balan August 9th, 2009 @ 04:01 PM
@elad: since two schema_migrations tables are created, each needs a different index
-
Tim Peters August 10th, 2009 @ 01:44 AM
Thanks for attending to this old issue :)
Minor comment: Christi's patch fixes the actual bug, but names the index starting with "unique" instead of the application prefix. The point of using a prefix is that all the objects in a shared schema can be grouped by name; the original patch named the index correctly.
-
Rizwan Reza August 10th, 2009 @ 02:41 AM
verified
The patch apply cleanly. All tests pass.
+1 I think Tim is right.
-
Jeremy Kemper August 10th, 2009 @ 06:52 AM
- State changed from incomplete to open
- Milestone set to 2.3.4
-
Repository August 10th, 2009 @ 06:59 AM
- State changed from open to committed
(from [7eaed4fefebf7a2084a7936775b6fc1b085f22ba]) Use table prefix and suffix for schema_migrations index.
[#1543 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/7eaed4fefebf7a2084a7936775b6fc... -
Repository August 10th, 2009 @ 06:59 AM
(from [25fe43bc14c0803ca28ae9cdf965a4f85413166a]) Add tests for scoping schema_migrations index by global table prefix and suffix
[#1543 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/25fe43bc14c0803ca28ae9cdf965a4... -
Repository August 10th, 2009 @ 06:59 AM
(from [3e35ba248154209d9c46e3d9fa78e98c1b5d0a96]) Add tests for scoping schema_migrations index by global table prefix and suffix
[#1543 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/3e35ba248154209d9c46e3d9fa78e9... -
Repository August 10th, 2009 @ 06:59 AM
(from [9e96f37edd598d698c9f39c9af114198e5000c70]) Use table prefix and suffix for schema_migrations index.
[#1543 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/9e96f37edd598d698c9f39c9af1141... -
Jeremy Kemper August 10th, 2009 @ 07:00 AM
- State changed from committed to open
- Tag changed from bug, bugmash, migrations, patch to bug, migrations, patch
-
Jeremy Kemper September 11th, 2009 @ 11:04 PM
- Milestone changed from 2.3.4 to 2.3.6
[milestone:id#50064 bulk edit command]
-
Rizwan Reza May 16th, 2010 @ 02:41 AM
- Tag changed from bug, migrations, patch to bug, bugmash, migrations, patch
-
Jeremy Kemper August 30th, 2010 @ 02:28 AM
- Milestone changed from 2.3.9 to 2.3.10
- Importance changed from to High
-
Tim Peters October 20th, 2010 @ 12:35 AM
why was this ticket re-opened? It was fixed in 2.3.4 and is still fixed.
-
Santiago Pastorino February 2nd, 2011 @ 07:57 PM
- State changed from open to resolved
- Assigned user changed from Frederick Cheung to Sam Ruby
Seems that this is already resolved, please comment if we need to re open it.
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
Attachments
Referenced by
- 1543 index "unique_schema_migrations" should use table prefix/suffix [#1543 state:committed]
- 1543 index "unique_schema_migrations" should use table prefix/suffix [#1543 state:committed]
- 1543 index "unique_schema_migrations" should use table prefix/suffix [#1543 state:committed]
- 1543 index "unique_schema_migrations" should use table prefix/suffix [#1543 state:committed]
- 1568 schema_statements#initialize_schema_migrations_table does not respect config.active_record.table_name_prefix Possibly related to #1543 (which includes a patch); that ...
- 2903 [patch] Unique index name for schema_migrations table Of #1543.
- 1568 schema_statements#initialize_schema_migrations_table does not respect config.active_record.table_name_prefix #1543
- 1210 table_name_prefix with db:schema:load causes double prefixes #1543
- 522 Rails 2.1 MySQL 6.0 schema_migrations index problem #1543
- 2903 [patch] Unique index name for schema_migrations table Now I noticed ticket #1543, which makes this one a duplic...
- 1210 table_name_prefix with db:schema:load causes double prefixes Pratik, while his "additionally" note does describe #1543...