Method: ActiveRecord::ConnectionAdapters::SchemaStatements#build_create_join_table_definition
- Defined in:
- activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
#build_create_join_table_definition(table_1, table_2, column_options: {}, **options) ⇒ Object
Builds a TableDefinition object for a join table.
This definition object contains information about the table that would be created if the same arguments were passed to #create_join_table. See #create_join_table for information about what arguments should be passed.
408 409 410 411 412 413 414 415 416 417 418 419 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb', line 408 def build_create_join_table_definition(table_1, table_2, column_options: {}, **) # :nodoc: join_table_name = find_join_table_name(table_1, table_2, ) .reverse_merge!(null: false, index: false) t1_ref, t2_ref = [table_1, table_2].map { |t| reference_name_for_table(t) } build_create_table_definition(join_table_name, **.merge!(id: false)) do |td| td.references t1_ref, ** td.references t2_ref, ** yield td if block_given? end end |