diff --git a/docker-compose.yml b/docker-compose.yml index 72124e28..00474383 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,7 +21,7 @@ services: context: . environment: DB_HOST: mysql - AR_VERSION: 7.0 + AR_VERSION: 7.1 volumes: - .:/usr/src/app depends_on: diff --git a/test/models/book.rb b/test/models/book.rb index 343ab197..0c7a73ac 100644 --- a/test/models/book.rb +++ b/test/models/book.rb @@ -2,7 +2,8 @@ class Book < ActiveRecord::Base belongs_to :topic, inverse_of: :books - belongs_to :tag, query_constraints: [:tag_id, :parent_id] + belongs_to :tag, foreign_key: [:tag_id, :parent_id] if ENV['AR_VERSION'].to_f < 7.1 + belongs_to :tag, query_constraints: [:tag_id, :parent_id] if ENV['AR_VERSION'].to_f >= 7.0 has_many :chapters, inverse_of: :book has_many :discounts, as: :discountable diff --git a/test/models/customer.rb b/test/models/customer.rb index d76d6656..16777e84 100644 --- a/test/models/customer.rb +++ b/test/models/customer.rb @@ -1,8 +1,13 @@ # frozen_string_literal: true class Customer < ActiveRecord::Base + has_many :orders, + inverse_of: :customer, + foreign_key: [:account_id, :customer_id], + primary_key: %i(account_id id) if ENV['AR_VERSION'].to_f < 7.1 + has_many :orders, inverse_of: :customer, query_constraints: [:account_id, :customer_id], - primary_key: %i(account_id id) + primary_key: %i(account_id id) if ENV['AR_VERSION'].to_f >= 7.0 end diff --git a/test/models/order.rb b/test/models/order.rb index eeb8581f..0ba5d8a6 100644 --- a/test/models/order.rb +++ b/test/models/order.rb @@ -1,8 +1,13 @@ # frozen_string_literal: true class Order < ActiveRecord::Base + belongs_to :customer, + inverse_of: :orders, + foreign_key: [:account_id, :customer_id], + primary_key: %i(account_id id) if ENV['AR_VERSION'].to_f < 7.1 + belongs_to :customer, inverse_of: :orders, query_constraints: [:account_id, :customer_id], - primary_key: %i(account_id id) + primary_key: %i(account_id id) if ENV['AR_VERSION'].to_f >= 7.0 end diff --git a/test/models/tag_alias.rb b/test/models/tag_alias.rb index 64149aaf..9d110c80 100644 --- a/test/models/tag_alias.rb +++ b/test/models/tag_alias.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true class TagAlias < ActiveRecord::Base - belongs_to :tag, query_constraints: [:tag_id, :parent_id], required: true + belongs_to :tag, foreign_key: [:tag_id, :parent_id], required: true if ENV['AR_VERSION'].to_f < 7.1 + belongs_to :tag, query_constraints: [:tag_id, :parent_id], required: true if ENV['AR_VERSION'].to_f >= 7.0 end