Commit 0f897538 authored by Nick Thomas's avatar Nick Thomas

EE: Inherit from ApplicationRecord instead of ActiveRecord::Base

parent 7116c4ec
# frozen_string_literal: true
class Approval < ActiveRecord::Base
class Approval < ApplicationRecord
belongs_to :user
belongs_to :merge_request
......
# frozen_string_literal: true
class Approver < ActiveRecord::Base
class Approver < ApplicationRecord
belongs_to :target, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
belongs_to :user
......
# frozen_string_literal: true
class ApproverGroup < ActiveRecord::Base
class ApproverGroup < ApplicationRecord
belongs_to :target, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
belongs_to :group
......
# frozen_string_literal: true
class BoardAssignee < ActiveRecord::Base
class BoardAssignee < ApplicationRecord
belongs_to :board
belongs_to :assignee, class_name: 'User'
......
# frozen_string_literal: true
class BoardLabel < ActiveRecord::Base
class BoardLabel < ApplicationRecord
belongs_to :board
belongs_to :label
......
......@@ -2,7 +2,7 @@
module Ci
module Sources
class Pipeline < ActiveRecord::Base
class Pipeline < ApplicationRecord
self.table_name = "ci_sources_pipelines"
belongs_to :project, class_name: Project
......
......@@ -46,7 +46,7 @@ module HasEnvironmentScope
# Note that the connection could be
# Gitlab::Database::LoadBalancing::ConnectionProxy
# which supports `quote` via `method_missing`
ActiveRecord::Base.connection.quote(value)
ApplicationRecord.connection.quote(value)
end
# The query is trying to find variables with scopes matching the
......
# frozen_string_literal: true
class DraftNote < ActiveRecord::Base
class DraftNote < ApplicationRecord
include DiffPositionableNote
include Gitlab::Utils::StrongMemoize
include Sortable
......
......@@ -160,7 +160,7 @@ module EE
return unless ::Group.supports_nested_objects?
result =
ActiveRecord::Base.connection.execute(
ApplicationRecord.connection.execute(
<<-SQL
WITH RECURSIVE descendants AS (
SELECT id, 1 depth
......
......@@ -121,7 +121,7 @@ module EE
owners = code_owners
if owners.present?
ActiveRecord::Base.transaction do
ApplicationRecord.transaction do
rule = approval_rules.code_owner.first
rule ||= approval_rules.code_owner.create!(name: ApprovalMergeRequestRule::DEFAULT_NAME_FOR_CODE_OWNER)
......
# frozen_string_literal: true
class Epic::Metrics < ActiveRecord::Base
class Epic::Metrics < ApplicationRecord
belongs_to :epic
def record!
......
# frozen_string_literal: true
class EpicIssue < ActiveRecord::Base
class EpicIssue < ApplicationRecord
include RelativePositioning
validates :epic, :issue, presence: true
......
# frozen_string_literal: true
module Geo
class CacheInvalidationEvent < ActiveRecord::Base
class CacheInvalidationEvent < ApplicationRecord
include Geo::Model
include Geo::Eventable
......
# frozen_string_literal: true
module Geo
class EventLog < ActiveRecord::Base
class EventLog < ApplicationRecord
include Geo::Model
include ::EachBatch
......
# frozen_string_literal: true
module Geo
class HashedStorageAttachmentsEvent < ActiveRecord::Base
class HashedStorageAttachmentsEvent < ApplicationRecord
include Geo::Model
include Geo::Eventable
......
# frozen_string_literal: true
module Geo
class HashedStorageMigratedEvent < ActiveRecord::Base
class HashedStorageMigratedEvent < ApplicationRecord
include Geo::Model
include Geo::Eventable
......
# frozen_string_literal: true
module Geo
class JobArtifactDeletedEvent < ActiveRecord::Base
class JobArtifactDeletedEvent < ApplicationRecord
include Geo::Model
include Geo::Eventable
......
# frozen_string_literal: true
module Geo
class LfsObjectDeletedEvent < ActiveRecord::Base
class LfsObjectDeletedEvent < ApplicationRecord
include Geo::Model
include Geo::Eventable
......
# frozen_string_literal: true
module Geo
class RepositoriesChangedEvent < ActiveRecord::Base
class RepositoriesChangedEvent < ApplicationRecord
include Geo::Model
include Geo::Eventable
......
# frozen_string_literal: true
module Geo
class RepositoryCreatedEvent < ActiveRecord::Base
class RepositoryCreatedEvent < ApplicationRecord
include Geo::Model
include Geo::Eventable
......
# frozen_string_literal: true
module Geo
class RepositoryDeletedEvent < ActiveRecord::Base
class RepositoryDeletedEvent < ApplicationRecord
include Geo::Model
include Geo::Eventable
......
# frozen_string_literal: true
module Geo
class RepositoryRenamedEvent < ActiveRecord::Base
class RepositoryRenamedEvent < ApplicationRecord
include Geo::Model
include Geo::Eventable
......
# frozen_string_literal: true
module Geo
class RepositoryUpdatedEvent < ActiveRecord::Base
class RepositoryUpdatedEvent < ApplicationRecord
include Geo::Model
include Geo::Eventable
......
# frozen_string_literal: true
module Geo
class ResetChecksumEvent < ActiveRecord::Base
class ResetChecksumEvent < ApplicationRecord
include Geo::Model
include Geo::Eventable
......
......@@ -3,7 +3,7 @@
# This module is intended to centralize all database access to the secondary
# tracking database for Geo.
module Geo
class TrackingBase < ActiveRecord::Base
class TrackingBase < ApplicationRecord
self.abstract_class = true
NOT_CONFIGURED_MSG = 'Geo secondary database is not configured'.freeze
......
# frozen_string_literal: true
module Geo
class UploadDeletedEvent < ActiveRecord::Base
class UploadDeletedEvent < ApplicationRecord
include Geo::Model
include Geo::Eventable
......
# frozen_string_literal: true
class GeoNode < ActiveRecord::Base
class GeoNode < ApplicationRecord
include Presentable
include Geo::SelectiveSync
......
# frozen_string_literal: true
class GeoNodeNamespaceLink < ActiveRecord::Base
class GeoNodeNamespaceLink < ApplicationRecord
belongs_to :geo_node, inverse_of: :namespaces
belongs_to :namespace
......
# frozen_string_literal: true
class GeoNodeStatus < ActiveRecord::Base
class GeoNodeStatus < ApplicationRecord
include ShaAttribute
belongs_to :geo_node
......
# frozen_string_literal: true
class GitlabSubscription < ActiveRecord::Base
class GitlabSubscription < ApplicationRecord
default_value_for :start_date, Date.today
belongs_to :namespace
......
# frozen_string_literal: true
class HistoricalData < ActiveRecord::Base
class HistoricalData < ApplicationRecord
validates :date, presence: true
# HistoricalData.during((Date.today - 1.year)..Date.today).average(:active_user_count)
......
# frozen_string_literal: true
class IndexStatus < ActiveRecord::Base
class IndexStatus < ApplicationRecord
belongs_to :project
validates :project_id, uniqueness: true, presence: true
......
# frozen_string_literal: true
class Insight < ActiveRecord::Base
class Insight < ApplicationRecord
belongs_to :group, foreign_key: :namespace_id
belongs_to :project
end
# frozen_string_literal: true
class IssueLink < ActiveRecord::Base
class IssueLink < ApplicationRecord
belongs_to :source, class_name: 'Issue'
belongs_to :target, class_name: 'Issue'
......
# frozen_string_literal: true
class LdapGroupLink < ActiveRecord::Base
class LdapGroupLink < ApplicationRecord
include Gitlab::Access
belongs_to :group
......
# frozen_string_literal: true
class License < ActiveRecord::Base
class License < ApplicationRecord
include ActionView::Helpers::NumberHelper
STARTER_PLAN = 'starter'.freeze
......
# frozen_string_literal: true
class NamespaceStatistics < ActiveRecord::Base
class NamespaceStatistics < ApplicationRecord
belongs_to :namespace
validates :namespace, presence: true
......
......@@ -6,7 +6,7 @@ module Operations
# "operations_feature_flags.active" column is not used in favor of
# operations_feature_flag_scopes's override policy.
# You can calculate actual `active` values with `for_environment` method.
class FeatureFlag < ActiveRecord::Base
class FeatureFlag < ApplicationRecord
self.table_name = 'operations_feature_flags'
belongs_to :project
......
# frozen_string_literal: true
module Operations
class FeatureFlagScope < ActiveRecord::Base
class FeatureFlagScope < ApplicationRecord
prepend HasEnvironmentScope
self.table_name = 'operations_feature_flag_scopes'
......
# frozen_string_literal: true
module Operations
class FeatureFlagsClient < ActiveRecord::Base
class FeatureFlagsClient < ApplicationRecord
include TokenAuthenticatable
self.table_name = 'operations_feature_flags_clients'
......
# frozen_string_literal: true
class Packages::MavenMetadatum < ActiveRecord::Base
class Packages::MavenMetadatum < ApplicationRecord
belongs_to :package
validates :package, presence: true
......
# frozen_string_literal: true
class Packages::Package < ActiveRecord::Base
class Packages::Package < ApplicationRecord
belongs_to :project
has_many :package_files
has_one :maven_metadatum, inverse_of: :package
......
# frozen_string_literal: true
class Packages::PackageFile < ActiveRecord::Base
class Packages::PackageFile < ApplicationRecord
belongs_to :package
validates :package, presence: true
......
# frozen_string_literal: true
class PathLock < ActiveRecord::Base
class PathLock < ApplicationRecord
belongs_to :project
belongs_to :user
......
......@@ -3,17 +3,17 @@
# `pg_replication_slots` is a PostgreSQL view
class PgReplicationSlot
def self.count
ActiveRecord::Base.connection.execute("SELECT COUNT(*) FROM pg_replication_slots;")
ApplicationRecord.connection.execute("SELECT COUNT(*) FROM pg_replication_slots;")
.first.fetch('count').to_i
end
def self.unused_slots_count
ActiveRecord::Base.connection.execute("SELECT COUNT(*) FROM pg_replication_slots WHERE active = 'f';")
ApplicationRecord.connection.execute("SELECT COUNT(*) FROM pg_replication_slots WHERE active = 'f';")
.first.fetch('count').to_i
end
def self.used_slots_count
ActiveRecord::Base.connection.execute("SELECT COUNT(*) FROM pg_replication_slots WHERE active = 't';")
ApplicationRecord.connection.execute("SELECT COUNT(*) FROM pg_replication_slots WHERE active = 't';")
.first.fetch('count').to_i
end
......@@ -21,7 +21,7 @@ class PgReplicationSlot
# https://www.skillslogic.com/blog/databases/checking-postgres-replication-lag
# http://bdr-project.org/docs/stable/monitoring-peers.html
def self.slots_retained_bytes
ActiveRecord::Base.connection.execute(<<-SQL.squish)
ApplicationRecord.connection.execute(<<-SQL.squish)
SELECT slot_name, database,
active, #{Gitlab::Database.pg_wal_lsn_diff}(#{Gitlab::Database.pg_current_wal_insert_lsn}(), restart_lsn)
AS retained_bytes
......@@ -32,7 +32,7 @@ class PgReplicationSlot
# returns the max number WAL space (in bytes) being used across the replication slots
def self.max_retained_wal
ActiveRecord::Base.connection.execute(<<-SQL.squish)
ApplicationRecord.connection.execute(<<-SQL.squish)
SELECT COALESCE(MAX(#{Gitlab::Database.pg_wal_lsn_diff}(#{Gitlab::Database.pg_current_wal_insert_lsn}(), restart_lsn)), 0)
FROM pg_replication_slots;
SQL
......@@ -40,7 +40,7 @@ class PgReplicationSlot
end
def self.max_replication_slots
ActiveRecord::Base.connection.execute(<<-SQL.squish)
ApplicationRecord.connection.execute(<<-SQL.squish)
SELECT setting FROM pg_settings WHERE name = 'max_replication_slots';
SQL
.first&.fetch('setting').to_i
......
# frozen_string_literal: true
class Plan < ActiveRecord::Base
class Plan < ApplicationRecord
PAID_HOSTED_PLANS = %w[bronze silver gold].freeze
ALL_HOSTED_PLANS = (PAID_HOSTED_PLANS + ['early_adopter']).freeze
......
# frozen_string_literal: true
class ProjectFeatureUsage < ActiveRecord::Base
class ProjectFeatureUsage < ApplicationRecord
self.primary_key = :project_id
JIRA_DVCS_CLOUD_FIELD = 'jira_dvcs_cloud_last_sync_at'.freeze
......
# frozen_string_literal: true
class ProjectRepositoryState < ActiveRecord::Base
class ProjectRepositoryState < ApplicationRecord
include IgnorableColumn
include ShaAttribute
......
# frozen_string_literal: true
class ProjectTracingSetting < ActiveRecord::Base
class ProjectTracingSetting < ApplicationRecord
belongs_to :project
validates :external_url, length: { maximum: 255 }, public_url: true
......
# frozen_string_literal: true
class PrometheusAlert < ActiveRecord::Base
class PrometheusAlert < ApplicationRecord
include Sortable
OPERATORS_MAP = {
......
# frozen_string_literal: true
class PrometheusAlertEvent < ActiveRecord::Base
class PrometheusAlertEvent < ApplicationRecord
belongs_to :project, required: true, validate: true, inverse_of: :prometheus_alert_events
belongs_to :prometheus_alert, required: true, validate: true, inverse_of: :prometheus_alert_events
......
# frozen_string_literal: true
class ProtectedBranch::UnprotectAccessLevel < ActiveRecord::Base
class ProtectedBranch::UnprotectAccessLevel < ApplicationRecord
include ProtectedBranchAccess
end
# frozen_string_literal: true
class ProtectedEnvironment < ActiveRecord::Base
class ProtectedEnvironment < ApplicationRecord
include ::Gitlab::Utils::StrongMemoize
belongs_to :project
......
# frozen_string_literal: true
class ProtectedEnvironment::DeployAccessLevel < ActiveRecord::Base
class ProtectedEnvironment::DeployAccessLevel < ApplicationRecord
ALLOWED_ACCESS_LEVELS = [
Gitlab::Access::MAINTAINER,
Gitlab::Access::DEVELOPER,
......
# frozen_string_literal: true
class PushRule < ActiveRecord::Base
class PushRule < ApplicationRecord
extend Gitlab::Cache::RequestCache
request_cache_key do
......
# frozen_string_literal: true
class SamlProvider < ActiveRecord::Base
class SamlProvider < ApplicationRecord
USER_ATTRIBUTES_LOCKED_FOR_MANAGED_ACCOUNTS = %i(email public_email commit_email notification_email).freeze
belongs_to :group
......
# frozen_string_literal: true
class SlackIntegration < ActiveRecord::Base
class SlackIntegration < ApplicationRecord
belongs_to :service
validates :team_id, presence: true
......
# frozen_string_literal: true
class SmartcardIdentity < ActiveRecord::Base
class SmartcardIdentity < ApplicationRecord
belongs_to :user
validates :user,
......
......@@ -2,7 +2,7 @@
# This class represents a software license.
# For use in the License Management feature.
class SoftwareLicense < ActiveRecord::Base
class SoftwareLicense < ApplicationRecord
include Presentable
validates :name, presence: true
......
......@@ -3,7 +3,7 @@
# This class represents a software license policy. Which means the fact that the user
# approves or not of the use of a certain software license in their project.
# For use in the License Management feature.
class SoftwareLicensePolicy < ActiveRecord::Base
class SoftwareLicensePolicy < ApplicationRecord
include Presentable
# Only allows modification of the approval status
......
# frozen_string_literal: true
class UsersOpsDashboardProject < ActiveRecord::Base
class UsersOpsDashboardProject < ApplicationRecord
belongs_to :project
belongs_to :user
......
# frozen_string_literal: true
module Vulnerabilities
class Feedback < ActiveRecord::Base
class Feedback < ApplicationRecord
self.table_name = 'vulnerability_feedback'
belongs_to :project
......
# frozen_string_literal: true
module Vulnerabilities
class Identifier < ActiveRecord::Base
class Identifier < ApplicationRecord
include ShaAttribute
self.table_name = "vulnerability_identifiers"
......
# frozen_string_literal: true
module Vulnerabilities
class Occurrence < ActiveRecord::Base
class Occurrence < ApplicationRecord
include ShaAttribute
include ::Gitlab::Utils::StrongMemoize
......
# frozen_string_literal: true
module Vulnerabilities
class OccurrenceIdentifier < ActiveRecord::Base
class OccurrenceIdentifier < ApplicationRecord
self.table_name = "vulnerability_occurrence_identifiers"
belongs_to :occurrence, class_name: 'Vulnerabilities::Occurrence'
......
# frozen_string_literal: true
module Vulnerabilities
class OccurrencePipeline < ActiveRecord::Base
class OccurrencePipeline < ApplicationRecord
self.table_name = "vulnerability_occurrence_pipelines"
belongs_to :occurrence, class_name: 'Vulnerabilities::Occurrence'
......
# frozen_string_literal: true
module Vulnerabilities
class Scanner < ActiveRecord::Base
class Scanner < ApplicationRecord
self.table_name = "vulnerability_scanners"
has_many :occurrences, class_name: 'Vulnerabilities::Occurrence'
......
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