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.

index "unique_schema_migrations" should use table prefix/suffix

#1543

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.

Reported by Tim Peters · December 10th, 2008 @ 06:32 AM

State: resolved
Milestone: 2.3.10
Assigned to: Sam Ruby Sam Ruby
Importance: High

Activity

  1. Jordi Bunster
    Jordi Bunster
    • 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 as create_table doesn't either.

    December 22nd, 2008 @ 11:07 PM

  2. Frederick Cheung
    Frederick Cheung
    • State changed from new to incomplete

    Looks reasonable to me, could we have a test for this too?

    December 23rd, 2008 @ 11:04 AM

  3. Pratik
    Pratik
    • Milestone cleared.
    • Assigned user set to Frederick Cheung

    January 18th, 2009 @ 07:03 AM

  4. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from bug, migrations, patch to bug, bugmash, migrations, patch

    August 4th, 2009 @ 06:11 PM

  5. Cristi Balan
  6. David Trasbo
    David Trasbo

    +1

    Patch applies cleanly to edge and the tests are passing.

    August 9th, 2009 @ 02:19 PM

  7. Elad Meidar
    Elad Meidar

    +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 ?

    August 9th, 2009 @ 03:45 PM

  8. Cristi Balan
    Cristi Balan

    @elad: since two schema_migrations tables are created, each needs a different index

    August 9th, 2009 @ 04:01 PM

  9. David Trasbo
  10. Tim Peters
    Tim Peters

    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.

    August 10th, 2009 @ 01:44 AM

  11. Rizwan Reza
    Rizwan Reza

    verified

    The patch apply cleanly. All tests pass.

    +1 I think Tim is right.

    August 10th, 2009 @ 02:41 AM

  12. Jeremy Kemper
    Jeremy Kemper
    • State changed from incomplete to open
    • Milestone set to 2.3.4

    August 10th, 2009 @ 06:52 AM

  13. Repository
  14. Repository
  15. Repository
  16. Repository
  17. Jeremy Kemper
    Jeremy Kemper
    • State changed from committed to open
    • Tag changed from bug, bugmash, migrations, patch to bug, migrations, patch

    August 10th, 2009 @ 07:00 AM

  18. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.4 to 2.3.6

    [milestone:id#50064 bulk edit command]

    September 11th, 2009 @ 11:04 PM

  19. Ryan Bigg
    Ryan Bigg

    Jeremy, why was this re-opened?

    May 9th, 2010 @ 10:16 PM

  20. Rizwan Reza
    Rizwan Reza
    • Tag changed from bug, migrations, patch to bug, bugmash, migrations, patch

    May 16th, 2010 @ 02:41 AM

  21. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.6 to 2.3.7

    May 23rd, 2010 @ 05:54 PM

  22. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.7 to 2.3.8

    May 24th, 2010 @ 09:40 AM

  23. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.8 to 2.3.9

    May 25th, 2010 @ 11:45 PM

  24. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.9 to 2.3.10
    • Importance changed from to High

    August 30th, 2010 @ 02:28 AM

  25. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 9th, 2010 @ 09:57 PM

  26. Ryan Bigg
    Ryan Bigg

    Automatic cleanup of spam.

    October 19th, 2010 @ 08:22 AM

  27. Tim Peters
    Tim Peters

    why was this ticket re-opened? It was fixed in 2.3.4 and is still fixed.

    October 20th, 2010 @ 12:35 AM

  28. Santiago Pastorino
    Santiago Pastorino
    • 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.

    February 2nd, 2011 @ 07:57 PM