mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
create_table
with :primary_key
option has no effect if id: false
is given
Use column definition with `primary_key: true` instead.
This commit is contained in:
parent
6c98dad59d
commit
7fae9ba054
3 changed files with 6 additions and 8 deletions
|
@ -1,7 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Country < ActiveRecord::Base
|
||||
self.primary_key = :country_id
|
||||
|
||||
has_and_belongs_to_many :treaties
|
||||
end
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Treaty < ActiveRecord::Base
|
||||
self.primary_key = :treaty_id
|
||||
|
||||
has_and_belongs_to_many :countries
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue