diff options
author | Ernst Rullmann <e.rullmann@gmail.com> | 2016-01-31 22:50:20 -0500 |
---|---|---|
committer | Ernst Rullmann <e.rullmann@gmail.com> | 2016-01-31 23:20:07 -0500 |
commit | 138c1db83e13cc01c54ac9657c8388aa46324582 (patch) | |
tree | face3127cde08566746fcf5d47f7620e5f3f9d97 /activerecord/lib/active_record/internal_metadata.rb | |
parent | 2f8ba24ec65d7a850e7ec0985d44be4a86da04c5 (diff) | |
download | rails-138c1db83e13cc01c54ac9657c8388aa46324582.tar.gz rails-138c1db83e13cc01c54ac9657c8388aa46324582.tar.bz2 rails-138c1db83e13cc01c54ac9657c8388aa46324582.zip |
Added references option to join tables
Fixes issue #22960
When creating join tables with the command
rails g migration CreateJoinTableShowroomUser showroom:references user:references
The migration will use references to create the joins and output:
class CreateJoinTableShowroomUser < ActiveRecord::Migration
def change
create_join_table :showrooms, :users do |t|
t.references :showroom, index: true, foreign_key: true
t.references :user, index: true, foreign_key: true
end
end
end
This allows for proper refrences with indexes and foreign keys to be easily used when
adding join tables. Without `:refrences` the normal output is generated:
class CreateJoinTableShowroomUser < ActiveRecord::Migration[5.0]
def change
create_join_table :showrooms, :users do |t|
# t.index [:showroom_id, :user_id]
# t.index [:user_id, :showroom_id]
end
end
end
Diffstat (limited to 'activerecord/lib/active_record/internal_metadata.rb')
0 files changed, 0 insertions, 0 deletions