提交 62c01d3c 编写于 作者: G Greg Molnar

add column type option to create_join_table to support uuid

上级 f5a59883
......@@ -329,12 +329,13 @@ def create_join_table(table_1, table_2, options = {})
column_options = options.delete(:column_options) || {}
column_options.reverse_merge!(null: false)
type = column_options.delete(:type) || :integer
t1_column, t2_column = [table_1, table_2].map{ |t| t.to_s.singularize.foreign_key }
create_table(join_table_name, options.merge!(id: false)) do |td|
td.integer t1_column, column_options
td.integer t2_column, column_options
td.send type, t1_column, column_options
td.send type, t2_column, column_options
yield td if block_given?
end
end
......
......@@ -132,6 +132,13 @@ def test_create_and_drop_join_table_with_common_prefix
end
end
if current_adapter?(:PostgreSQLAdapter)
def test_create_join_table_with_uuid
connection.create_join_table :artists, :musics, column_options: { type: :uuid }
assert_equal [:uuid, :uuid], connection.columns(:artists_musics).map(&:type)
end
end
private
def with_table_cleanup
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册