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.

table_name_prefix with db:schema:load causes double prefixes

#1210

1: set config.active_record.table_name_prefix = 'pfx_' in /config/environment.rb

2: create some migrations. For example:


    create_table :blogs do |t|
      t.string  :name
      t.timestamps
    end

3: run rake db:migrate. The generated schema is as follows:


    create_table "pfx_blogs", :force => true do |t|
      t.string "name"
      t.timestamps
    end

    create_table "pfx_schema_migrations", :primary_key => "version", :force => true do |t|
    end

    add_index "pfx_schema_migrations", ["version"], :name => "unique_schema_migrations", :unique => true

4: run rake test. The tables created by db:schema:load are as follows:

  • pfx_schema_migrations
  • pfx_pfx_schema_migrations
  • pfx_pfx_blogs

Additionally, I don't know whether this is related, but under SQLite3, I get the following on rake test after a rake db:migrate:

SQLite3::SQLException: index unique_schema_migrations already exists: CREATE UNIQUE INDEX "unique_schema_migrations" ON "pfx_schema_migrations" ("version")

Reported by Gaius Centus Novus · October 14th, 2008 @ 06:04 PM

State: open
Milestone: 2.3.10
Assigned to: nobody
Importance: none

Activity

  1. Pratik
  2. Ben Woosley
    Ben Woosley
    • Assigned user set to Pratik
    • Importance changed from to

    Pratik, while his "additionally" note does describe #1543 index "unique_schema_migrations" should use table prefix/suffix, the rest does not. I can confirm the duplicate prefix from db:test:prepare is a real problem on 2.3.5 at least.

    July 1st, 2010 @ 11:00 PM

  3. Pratik
    Pratik
    • Assigned user cleared.
    • State changed from duplicate to open

    July 1st, 2010 @ 11:08 PM

  4. Neeraj Singh
    Neeraj Singh
    • Milestone changed from 2.x to 2.3.9

    July 29th, 2010 @ 09:23 PM

  5. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.9 to 2.3.10

    August 30th, 2010 @ 02:28 AM

  6. Jeff Kreeftmeijer
    Jeff Kreeftmeijer
    • Tag cleared.

    Automatic cleanup of spam.

    November 8th, 2010 @ 08:28 AM

  7. DLitz
    DLitz

    The problem is that the SchemaDumper isn't aware of table_name_(prefix|suffix). The attached patch against Rails 2.3.10 fixes this issue.

    December 20th, 2010 @ 08:57 PM

  8. rails
    rails

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    March 21st, 2011 @ 12:00 AM

  9. rails
    rails
    • State changed from open to stale

    March 21st, 2011 @ 12:00 AM

  10. DLitz
    DLitz

    This is a bug against 2-3-stable, not 3-0-stable, and yes it still applies.

    March 21st, 2011 @ 02:41 PM

  11. DLitz
    DLitz
    • State changed from stale to open

    [state:open]

    March 21st, 2011 @ 02:41 PM