diff options
Diffstat (limited to 'app/models/concerns/integrations')
-rw-r--r-- | app/models/concerns/integrations/base_data_fields.rb | 17 | ||||
-rw-r--r-- | app/models/concerns/integrations/has_data_fields.rb | 4 | ||||
-rw-r--r-- | app/models/concerns/integrations/has_web_hook.rb | 1 |
3 files changed, 4 insertions, 18 deletions
diff --git a/app/models/concerns/integrations/base_data_fields.rb b/app/models/concerns/integrations/base_data_fields.rb index 11bdd3aae7b..2870922d90d 100644 --- a/app/models/concerns/integrations/base_data_fields.rb +++ b/app/models/concerns/integrations/base_data_fields.rb @@ -4,15 +4,10 @@ module Integrations module BaseDataFields extend ActiveSupport::Concern - LEGACY_FOREIGN_KEY_NAME = %w( - Integrations::IssueTrackerData - Integrations::JiraTrackerData - ).freeze - included do # TODO: Once we rename the tables we can't rely on `table_name` anymore. # https://gitlab.com/gitlab-org/gitlab/-/issues/331953 - belongs_to :integration, inverse_of: self.table_name.to_sym, foreign_key: foreign_key_name + belongs_to :integration, inverse_of: self.table_name.to_sym, foreign_key: :integration_id validates :integration, presence: true end @@ -26,16 +21,6 @@ module Integrations algorithm: 'aes-256-gcm' } end - - private - - # Older data field models use the `service_id` foreign key for the - # integration association. - def foreign_key_name - return :service_id if self.name.in?(LEGACY_FOREIGN_KEY_NAME) - - :integration_id - end end def activated? diff --git a/app/models/concerns/integrations/has_data_fields.rb b/app/models/concerns/integrations/has_data_fields.rb index 635147a2f3c..2671df873aa 100644 --- a/app/models/concerns/integrations/has_data_fields.rb +++ b/app/models/concerns/integrations/has_data_fields.rb @@ -44,8 +44,8 @@ module Integrations end included do - has_one :issue_tracker_data, autosave: true, inverse_of: :integration, foreign_key: :service_id, class_name: 'Integrations::IssueTrackerData' - has_one :jira_tracker_data, autosave: true, inverse_of: :integration, foreign_key: :service_id, class_name: 'Integrations::JiraTrackerData' + has_one :issue_tracker_data, autosave: true, inverse_of: :integration, foreign_key: :integration_id, class_name: 'Integrations::IssueTrackerData' + has_one :jira_tracker_data, autosave: true, inverse_of: :integration, foreign_key: :integration_id, class_name: 'Integrations::JiraTrackerData' has_one :zentao_tracker_data, autosave: true, inverse_of: :integration, foreign_key: :integration_id, class_name: 'Integrations::ZentaoTrackerData' def data_fields diff --git a/app/models/concerns/integrations/has_web_hook.rb b/app/models/concerns/integrations/has_web_hook.rb index bc28c32695c..e6ca6cc7938 100644 --- a/app/models/concerns/integrations/has_web_hook.rb +++ b/app/models/concerns/integrations/has_web_hook.rb @@ -6,6 +6,7 @@ module Integrations included do after_save :update_web_hook!, if: :activated? + has_one :service_hook, inverse_of: :integration, foreign_key: :service_id end # Return the URL to be used for the webhook. |