Commit b003363e authored by Thong Kuah's avatar Thong Kuah

Suppress composite primary key warning

These are all known cases, and there's no harm in the composite pk, so
we can stop emit this warnings for these models
parent 6f420923
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
module Ci module Ci
class BuildTraceSection < ApplicationRecord class BuildTraceSection < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
extend Gitlab::Ci::Model extend Gitlab::Ci::Model
belongs_to :build, class_name: 'Ci::Build' belongs_to :build, class_name: 'Ci::Build'
......
# frozen_string_literal: true
# When extended, silences this warning below:
# WARNING: Active Record does not support composite primary key.
#
# project_authorizations has composite primary key. Composite primary key is ignored.
#
# See https://gitlab.com/gitlab-org/gitlab/-/issues/292909
module SuppressCompositePrimaryKeyWarning
extend ActiveSupport::Concern
private
def suppress_composite_primary_key(pk)
silence_warnings do
super
end
end
end
# frozen_string_literal: true # frozen_string_literal: true
class DeploymentMergeRequest < ApplicationRecord class DeploymentMergeRequest < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
belongs_to :deployment, optional: false belongs_to :deployment, optional: false
belongs_to :merge_request, optional: false belongs_to :merge_request, optional: false
......
# frozen_string_literal: true # frozen_string_literal: true
class IssueAssignee < ApplicationRecord class IssueAssignee < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
belongs_to :issue belongs_to :issue
belongs_to :assignee, class_name: "User", foreign_key: :user_id, inverse_of: :issue_assignees belongs_to :assignee, class_name: "User", foreign_key: :user_id, inverse_of: :issue_assignees
......
# frozen_string_literal: true # frozen_string_literal: true
class MergeRequestContextCommitDiffFile < ApplicationRecord class MergeRequestContextCommitDiffFile < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
include Gitlab::EncodingHelper include Gitlab::EncodingHelper
include ShaAttribute include ShaAttribute
include DiffFile include DiffFile
......
# frozen_string_literal: true # frozen_string_literal: true
class MergeRequestDiffCommit < ApplicationRecord class MergeRequestDiffCommit < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
include BulkInsertSafe include BulkInsertSafe
include ShaAttribute include ShaAttribute
include CachedCommit include CachedCommit
......
# frozen_string_literal: true # frozen_string_literal: true
class MergeRequestDiffFile < ApplicationRecord class MergeRequestDiffFile < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
include BulkInsertSafe include BulkInsertSafe
include Gitlab::EncodingHelper include Gitlab::EncodingHelper
include DiffFile include DiffFile
......
# frozen_string_literal: true # frozen_string_literal: true
class MilestoneRelease < ApplicationRecord class MilestoneRelease < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
belongs_to :milestone belongs_to :milestone
belongs_to :release belongs_to :release
......
# frozen_string_literal: true # frozen_string_literal: true
class ProjectAuthorization < ApplicationRecord class ProjectAuthorization < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
include FromUnion include FromUnion
belongs_to :user belongs_to :user
......
# frozen_string_literal: true # frozen_string_literal: true
class ProjectPagesMetadatum < ApplicationRecord class ProjectPagesMetadatum < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
include EachBatch include EachBatch
self.primary_key = :project_id self.primary_key = :project_id
......
# frozen_string_literal: true # frozen_string_literal: true
class PushEventPayload < ApplicationRecord class PushEventPayload < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
include ShaAttribute include ShaAttribute
belongs_to :event, inverse_of: :push_event_payload belongs_to :event, inverse_of: :push_event_payload
......
# frozen_string_literal: true # frozen_string_literal: true
class RepositoryLanguage < ApplicationRecord class RepositoryLanguage < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
belongs_to :project belongs_to :project
belongs_to :programming_language belongs_to :programming_language
......
# frozen_string_literal: true # frozen_string_literal: true
class UserInteractedProject < ApplicationRecord class UserInteractedProject < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
belongs_to :user belongs_to :user
belongs_to :project belongs_to :project
......
# frozen_string_literal: true # frozen_string_literal: true
class Analytics::LanguageTrend::RepositoryLanguage < ApplicationRecord class Analytics::LanguageTrend::RepositoryLanguage < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
belongs_to :programming_language belongs_to :programming_language
belongs_to :project belongs_to :project
end end
...@@ -2,4 +2,5 @@ ...@@ -2,4 +2,5 @@
# Model for join table between ApprovalProjectRule and ProtectedBranch # Model for join table between ApprovalProjectRule and ProtectedBranch
class ApprovalProjectRulesProtectedBranch < ApplicationRecord class ApprovalProjectRulesProtectedBranch < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
end end
# frozen_string_literal: true # frozen_string_literal: true
class UsersSecurityDashboardProject < ApplicationRecord class UsersSecurityDashboardProject < ApplicationRecord
extend SuppressCompositePrimaryKeyWarning
SECURITY_DASHBOARD_PROJECTS_LIMIT = 1000 SECURITY_DASHBOARD_PROJECTS_LIMIT = 1000
belongs_to :project belongs_to :project
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment