mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Don't define a default primary key in the schema dumper.
[#1908 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
This commit is contained in:
committed by
Jeremy Kemper
parent
a25296ab05
commit
9aa9bad024
@@ -84,7 +84,6 @@ HEADER
|
||||
elsif @connection.respond_to?(:primary_key)
|
||||
pk = @connection.primary_key(table)
|
||||
end
|
||||
pk ||= 'id'
|
||||
|
||||
tbl.print " create_table #{table.inspect}"
|
||||
if columns.detect { |c| c.name == pk }
|
||||
@@ -180,4 +179,4 @@ HEADER
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -190,4 +190,12 @@ class SchemaDumperTest < ActiveRecord::TestCase
|
||||
output = stream.string
|
||||
assert_match %r{:precision => 3,[[:space:]]+:scale => 2,[[:space:]]+:default => 2.78}, output
|
||||
end
|
||||
|
||||
def test_schema_dump_keeps_id_column_when_id_is_false_and_id_column_added
|
||||
output = standard_dump
|
||||
match = output.match(%r{create_table "goofy_string_id"(.*)do.*\n(.*)\n})
|
||||
assert_not_nil(match, "goofy_string_id table not found")
|
||||
assert_match %r(:id => false), match[1], "no table id not preserved"
|
||||
assert_match %r{t.string[[:space:]]+"id",[[:space:]]+:null => false$}, match[2], "non-primary key id column not preserved"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user