aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-12-22 13:09:49 -0700
committerSean Griffin <sean@thoughtbot.com>2014-12-22 13:47:10 -0700
commit99a6f9e60ea55924b44f894a16f8de0162cf2702 (patch)
treeec97f3ea702a58b18b4a94a58f08ca5bbd512080 /activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
parenta9c0c46263dcafcf01944246e31cbe5650ee605e (diff)
downloadrails-99a6f9e60ea55924b44f894a16f8de0162cf2702.tar.gz
rails-99a6f9e60ea55924b44f894a16f8de0162cf2702.tar.bz2
rails-99a6f9e60ea55924b44f894a16f8de0162cf2702.zip
Add a `foreign_key` option to `references` while creating the table
Rather than having to do: create_table :posts do |t| t.references :user end add_foreign_key :posts, :users You can instead do: create_table :posts do |t| t.references :user, foreign_key: true end Similar to the `index` option, you can also pass a hash. This will be passed as the options to `add_foreign_key`. e.g.: create_table :posts do |t| t.references :user, foreign_key: { primary_key: :other_id } end is equivalent to create_table :posts do |t| t.references :user end add_foreign_key :posts, :users, primary_key: :other_id
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb')
0 files changed, 0 insertions, 0 deletions