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.

Schema dumper ignores custom id column even when :id => false

#1908

Given the following migration:


create_table(:table, :id => false) do |t|
  t.string :id, :null => false, :limit => 40
end

the schema dumper would generate the following:


create_table "table", :force => true do |t|
end

This is due to it automatically assuming the ID is the primary key. I got around this problem by checking if the column is also an integer. Not sure if it's the best way, but it just drove me crazy for a good while since my tests would fail, but everything worked fine in the console. I have attached my simple patch.

Reported by Tristan Dunn · February 7th, 2009 @ 11:42 PM

State: committed
Milestone: 2.3.4
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. dust
    dust

    +1

    I spent a nice chunk of yesterday tracking this issue down on my system, and this patch (along with re-dumping the schema, obviously) fixes the issue for me.

    March 3rd, 2009 @ 03:29 PM

  2. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from primary_key, schema to bugmash, primary_key, schema

    August 5th, 2009 @ 02:21 PM

  3. Tristan Dunn
    Tristan Dunn

    New patch to simply not default the primary key to ID in the schema dumper. If you don't define it then the connection should find it.

    August 8th, 2009 @ 11:35 PM

  4. Tristan Dunn
    Tristan Dunn

    Seems to be some confusion on which branch I should be working on so I made one on master and 2-3-stable.

    August 8th, 2009 @ 11:48 PM

  5. Dan Croak
    Dan Croak

    +1 verified 2-3-stable patch applies clean and tests run green. Implementation looks good to me.

    August 8th, 2009 @ 11:56 PM

  6. Jeremy Kemper
    Jeremy Kemper
    • Assigned user set to Jeremy Kemper
    • Tag changed from bugmash, primary_key, schema to primary_key, schema
    • State changed from new to committed
    • Milestone changed from 2.x to 2.3.4

    2-3-stable: 9aa9bad024253a7ab2adee63df8185dc876393f9

    master: 791cccaedab9c3e975b00135db76047ad4435611

    August 9th, 2009 @ 03:33 AM

  7. Repository
  8. Repository