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.

[patch] Unique index name for schema_migrations table

#2903

In environment where two rails projects coexist within one database, we need to use unique name of index of "schema_migrations" table. Since we now support unique name of "schema_migrations" table only using "Base.table_name_prefix" and "Base.table_name_suffix", the same should be sufficient for the "unique_schema_migrations" index.

Postgresql complaints ERROR: relation "unique_schema_migrations" already exists'' if there is already a rails project in the database (with different table names prefix).

Patch for activerecord is attached.

(Also please see the ticket #2751 [patch] SchemaDumper works bad with table_prefix, where Christoph fixes a slightly-related table name 'schema_migrations' is hard coded'' problem in activerecord's "lib/active_record/schema_dumper.rb" file.)

Reported by Rudolf Gavlas · July 12th, 2009 @ 03:19 PM

State: duplicate
Milestone: 3.x
Assigned to: Ryan Bigg Ryan Bigg
Importance: none

Activity

  1. Pratik
    Pratik

    LH seems to be messing up the attachments lately. Could you please reupload the patch ?

    Thanks.

    July 14th, 2009 @ 12:55 PM

  2. Rudolf Gavlas
    Rudolf Gavlas

    Sure. I'll also paste it here verbatim, it is not big at all. I am hitting another LH bug probably -- I can't open the page with formatting help right now, so here it is FWIW just pasted without any formatting:

    --- lib/active_record/connection_adapters/abstract/schema_statements.rb-orig 2009-07-12 15:47:09.000000000 +0200 +++ lib/active_record/connection_adapters/abstract/schema_statements.rb 2009-07-12 15:48:39.000000000 +0200 @@ -321,7 +321,7 @@

             schema_migrations_table.column :version, :string, :null => false
           end
           add_index sm_table, :version, :unique => true,
    
    •      :name => 'unique_schema_migrations'
      
    •      :name => Base.table_name_prefix + 'unique_schema_migrations' + Base.table_name_suffix
      
         # Backwards-compatibility: if we find schema_info, assume we've
         # migrated up to that point:
      

    July 14th, 2009 @ 03:08 PM

  3. Rudolf Gavlas
    Rudolf Gavlas

    Now I noticed ticket #1543 index "unique_schema_migrations" should use table prefix/suffix, which makes this one a duplicate. This problem report can be closed.

    October 9th, 2009 @ 08:28 PM

  4. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  5. Dan Pickett
    Dan Pickett
    • Assigned user set to Ryan Bigg

    May 9th, 2010 @ 07:04 PM

  6. Ryan Bigg