diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-10-27 22:53:17 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-10-27 22:57:16 +0900 |
commit | 7fae9ba0544c092ecca7fac0856766a3c8100bcc (patch) | |
tree | 5e3646189fdc549069e01afa12113671b107ca24 /activerecord/test | |
parent | 6c98dad59d29bc26b4957d2b7547b16bc9919526 (diff) | |
download | rails-7fae9ba0544c092ecca7fac0856766a3c8100bcc.tar.gz rails-7fae9ba0544c092ecca7fac0856766a3c8100bcc.tar.bz2 rails-7fae9ba0544c092ecca7fac0856766a3c8100bcc.zip |
`create_table` with `:primary_key` option has no effect if `id: false` is given
Use column definition with `primary_key: true` instead.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/models/country.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/treaty.rb | 2 | ||||
-rw-r--r-- | activerecord/test/schema/schema.rb | 10 |
3 files changed, 6 insertions, 8 deletions
diff --git a/activerecord/test/models/country.rb b/activerecord/test/models/country.rb index 0c84a40de2..4b4a276a98 100644 --- a/activerecord/test/models/country.rb +++ b/activerecord/test/models/country.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true class Country < ActiveRecord::Base - self.primary_key = :country_id - has_and_belongs_to_many :treaties end diff --git a/activerecord/test/models/treaty.rb b/activerecord/test/models/treaty.rb index 5c1d75aa09..b87a757d2a 100644 --- a/activerecord/test/models/treaty.rb +++ b/activerecord/test/models/treaty.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true class Treaty < ActiveRecord::Base - self.primary_key = :treaty_id - has_and_belongs_to_many :countries end diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index 56ff81af29..a3989cc66d 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -983,14 +983,16 @@ ActiveRecord::Schema.define do t.references :wheelable, polymorphic: true end - create_table :countries, force: true, id: false, primary_key: "country_id" do |t| - t.string :country_id + create_table :countries, force: true, id: false do |t| + t.string :country_id, primary_key: true t.string :name end - create_table :treaties, force: true, id: false, primary_key: "treaty_id" do |t| - t.string :treaty_id + + create_table :treaties, force: true, id: false do |t| + t.string :treaty_id, primary_key: true t.string :name end + create_table :countries_treaties, force: true, primary_key: [:country_id, :treaty_id] do |t| t.string :country_id, null: false t.string :treaty_id, null: false |