mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-30 06:31:16 +00:00
Resolve conflict in db/schema.rb
This commit is contained in:
@@ -9,9 +9,9 @@ module PaymentMethodDistributors
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
has_and_belongs_to_many :distributors, join_table: 'distributors_payment_methods',
|
||||
class_name: 'Enterprise',
|
||||
foreign_key: 'payment_method_id',
|
||||
association_foreign_key: 'distributor_id'
|
||||
has_many :distributor_payment_methods, dependent: :destroy
|
||||
has_many :distributors, through: :distributor_payment_methods,
|
||||
class_name: 'Enterprise',
|
||||
foreign_key: 'distributor_id'
|
||||
end
|
||||
end
|
||||
|
||||
7
app/models/distributor_payment_method.rb
Normal file
7
app/models/distributor_payment_method.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DistributorPaymentMethod < ApplicationRecord
|
||||
self.table_name = "distributors_payment_methods"
|
||||
belongs_to :payment_method, class_name: "Spree::PaymentMethod", touch: true
|
||||
belongs_to :distributor, class_name: "Enterprise", touch: true
|
||||
end
|
||||
@@ -69,10 +69,9 @@ class Enterprise < ApplicationRecord
|
||||
has_many :users, through: :enterprise_roles
|
||||
belongs_to :owner, class_name: 'Spree::User',
|
||||
inverse_of: :owned_enterprises
|
||||
has_and_belongs_to_many :payment_methods, join_table: 'distributors_payment_methods',
|
||||
class_name: 'Spree::PaymentMethod',
|
||||
foreign_key: 'distributor_id'
|
||||
has_many :distributor_payment_methods, foreign_key: :distributor_id
|
||||
has_many :distributor_shipping_methods, foreign_key: :distributor_id
|
||||
has_many :payment_methods, through: :distributor_payment_methods
|
||||
has_many :shipping_methods, through: :distributor_shipping_methods
|
||||
has_many :customers
|
||||
has_many :inventory_items
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class AddIdAndTimestampsToDistributorPaymentMethods < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :distributors_payment_methods, :id, :primary_key
|
||||
add_column :distributors_payment_methods, :created_at, :datetime
|
||||
add_column :distributors_payment_methods, :updated_at, :datetime
|
||||
end
|
||||
end
|
||||
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2022_10_04_165343) do
|
||||
ActiveRecord::Schema.define(version: 2022_10_07_103614) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_stat_statements"
|
||||
@@ -107,9 +107,11 @@ ActiveRecord::Schema.define(version: 2022_10_04_165343) do
|
||||
t.index ["priority", "run_at"], name: "delayed_jobs_priority"
|
||||
end
|
||||
|
||||
create_table "distributors_payment_methods", id: false, force: :cascade do |t|
|
||||
create_table "distributors_payment_methods", force: :cascade do |t|
|
||||
t.integer "distributor_id"
|
||||
t.integer "payment_method_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.index ["distributor_id"], name: "index_distributors_payment_methods_on_distributor_id"
|
||||
t.index ["payment_method_id"], name: "index_distributors_payment_methods_on_payment_method_id"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user