add_reference
should respect column position for both reference id and type columns
Fixes #30496.
This commit is contained in:
parent
47200f502d
commit
17faed96b4
@ -148,7 +148,7 @@ def as_options(value)
|
||||
end
|
||||
|
||||
def polymorphic_options
|
||||
as_options(polymorphic).merge(null: options[:null])
|
||||
as_options(polymorphic).merge(options.slice(:null, :first, :after))
|
||||
end
|
||||
|
||||
def index_options
|
||||
|
@ -52,6 +52,16 @@ def test_change_column_with_positioning
|
||||
conn.change_column :testings, :second, :integer, after: :third
|
||||
assert_equal %w(first third second), conn.columns(:testings).map(&:name)
|
||||
end
|
||||
|
||||
def test_add_reference_with_positioning_first
|
||||
conn.add_reference :testings, :new, polymorphic: true, first: true
|
||||
assert_equal %w(new_id new_type first second third), conn.columns(:testings).map(&:name)
|
||||
end
|
||||
|
||||
def test_add_reference_with_positioning_after
|
||||
conn.add_reference :testings, :new, polymorphic: true, after: :first
|
||||
assert_equal %w(first new_id new_type second third), conn.columns(:testings).map(&:name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user