diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-11-10 13:11:53 +1100 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-11-12 22:06:08 +0100 |
commit | f0f31d61755a18ccc2a0b253da6ea88b46f2a6d1 (patch) | |
tree | 5d366aabe23b6382bf57bb8320693060b71d658a | |
parent | de0bbe13e31e63e94cab86882524b5d06bcdcbc2 (diff) | |
download | gitlab-ce-f0f31d61755a18ccc2a0b253da6ea88b46f2a6d1.tar.gz |
[Rails5] Replace ActiveRecord::Base with ApplicationRecord
350 files changed, 493 insertions, 493 deletions
diff --git a/app/mailers/previews/notify_preview.rb b/app/mailers/previews/notify_preview.rb index e7e8d96eca4..323f3332d67 100644 --- a/app/mailers/previews/notify_preview.rb +++ b/app/mailers/previews/notify_preview.rb @@ -186,7 +186,7 @@ class NotifyPreview < ActionMailer::Preview def cleanup email = nil - ActiveRecord::Base.transaction do + ApplicationRecord.transaction do email = yield raise ActiveRecord::Rollback end diff --git a/app/models/abuse_report.rb b/app/models/abuse_report.rb index 1b78fd04ebb..a3a1748142f 100644 --- a/app/models/abuse_report.rb +++ b/app/models/abuse_report.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AbuseReport < ActiveRecord::Base +class AbuseReport < ApplicationRecord include CacheMarkdownField cache_markdown_field :message, pipeline: :single_line diff --git a/app/models/appearance.rb b/app/models/appearance.rb index bffba3e13fa..05ccda72a84 100644 --- a/app/models/appearance.rb +++ b/app/models/appearance.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Appearance < ActiveRecord::Base +class Appearance < ApplicationRecord include CacheableAttributes include CacheMarkdownField include ObjectStorage::BackgroundMove diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 207ffae873a..95add7a17af 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ApplicationSetting < ActiveRecord::Base +class ApplicationSetting < ApplicationRecord include CacheableAttributes include CacheMarkdownField include TokenAuthenticatable diff --git a/app/models/application_setting/term.rb b/app/models/application_setting/term.rb index 498701ba22b..723540c9b91 100644 --- a/app/models/application_setting/term.rb +++ b/app/models/application_setting/term.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class ApplicationSetting - class Term < ActiveRecord::Base + class Term < ApplicationRecord include CacheMarkdownField has_many :term_agreements diff --git a/app/models/audit_event.rb b/app/models/audit_event.rb index 8508c88d406..6ef2914ac11 100644 --- a/app/models/audit_event.rb +++ b/app/models/audit_event.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AuditEvent < ActiveRecord::Base +class AuditEvent < ApplicationRecord serialize :details, Hash # rubocop:disable Cop/ActiveRecordSerialize belongs_to :user, foreign_key: :author_id diff --git a/app/models/award_emoji.rb b/app/models/award_emoji.rb index ddc516ccb60..e26162f6151 100644 --- a/app/models/award_emoji.rb +++ b/app/models/award_emoji.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AwardEmoji < ActiveRecord::Base +class AwardEmoji < ApplicationRecord DOWNVOTE_NAME = "thumbsdown".freeze UPVOTE_NAME = "thumbsup".freeze diff --git a/app/models/badge.rb b/app/models/badge.rb index f016654206b..a244ed473de 100644 --- a/app/models/badge.rb +++ b/app/models/badge.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Badge < ActiveRecord::Base +class Badge < ApplicationRecord include FromUnion # This structure sets the placeholders that the urls diff --git a/app/models/board.rb b/app/models/board.rb index a137863456c..7dba22a127b 100644 --- a/app/models/board.rb +++ b/app/models/board.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Board < ActiveRecord::Base +class Board < ApplicationRecord belongs_to :group belongs_to :project diff --git a/app/models/board_group_recent_visit.rb b/app/models/board_group_recent_visit.rb index 92abbb67222..eb11915ef3f 100644 --- a/app/models/board_group_recent_visit.rb +++ b/app/models/board_group_recent_visit.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Tracks which boards in a specific group a user has visited -class BoardGroupRecentVisit < ActiveRecord::Base +class BoardGroupRecentVisit < ApplicationRecord belongs_to :user belongs_to :group belongs_to :board diff --git a/app/models/board_project_recent_visit.rb b/app/models/board_project_recent_visit.rb index 7cffff906d8..4eeb23d1b26 100644 --- a/app/models/board_project_recent_visit.rb +++ b/app/models/board_project_recent_visit.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Tracks which boards in a specific project a user has visited -class BoardProjectRecentVisit < ActiveRecord::Base +class BoardProjectRecentVisit < ApplicationRecord belongs_to :user belongs_to :project belongs_to :board diff --git a/app/models/broadcast_message.rb b/app/models/broadcast_message.rb index baf8adb318b..8c74f7465e4 100644 --- a/app/models/broadcast_message.rb +++ b/app/models/broadcast_message.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class BroadcastMessage < ActiveRecord::Base +class BroadcastMessage < ApplicationRecord include CacheMarkdownField include Sortable diff --git a/app/models/chat_name.rb b/app/models/chat_name.rb index 03b0af53046..0041595baba 100644 --- a/app/models/chat_name.rb +++ b/app/models/chat_name.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ChatName < ActiveRecord::Base +class ChatName < ApplicationRecord LAST_USED_AT_INTERVAL = 1.hour belongs_to :service diff --git a/app/models/chat_team.rb b/app/models/chat_team.rb index 4e724f9adf7..52b5a7b4a91 100644 --- a/app/models/chat_team.rb +++ b/app/models/chat_team.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ChatTeam < ActiveRecord::Base +class ChatTeam < ApplicationRecord validates :team_id, presence: true validates :namespace, uniqueness: true diff --git a/app/models/ci/build_metadata.rb b/app/models/ci/build_metadata.rb index 9d588b862bd..1f7e9d3dbb5 100644 --- a/app/models/ci/build_metadata.rb +++ b/app/models/ci/build_metadata.rb @@ -3,7 +3,7 @@ module Ci # The purpose of this class is to store Build related data that can be disposed. # Data that should be persisted forever, should be stored with Ci::Build model. - class BuildMetadata < ActiveRecord::Base + class BuildMetadata < ApplicationRecord extend Gitlab::Ci::Model include Presentable include ChronicDurationAttribute diff --git a/app/models/ci/build_runner_session.rb b/app/models/ci/build_runner_session.rb index 457d7eeab6a..061eff090f5 100644 --- a/app/models/ci/build_runner_session.rb +++ b/app/models/ci/build_runner_session.rb @@ -3,7 +3,7 @@ module Ci # The purpose of this class is to store Build related runner session. # Data will be removed after transitioning from running to any state. - class BuildRunnerSession < ActiveRecord::Base + class BuildRunnerSession < ApplicationRecord extend Gitlab::Ci::Model self.table_name = 'ci_builds_runner_session' diff --git a/app/models/ci/build_trace_chunk.rb b/app/models/ci/build_trace_chunk.rb index 108874b75a6..6220d8427c2 100644 --- a/app/models/ci/build_trace_chunk.rb +++ b/app/models/ci/build_trace_chunk.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class BuildTraceChunk < ActiveRecord::Base + class BuildTraceChunk < ApplicationRecord include FastDestroyAll include ::Gitlab::ExclusiveLeaseHelpers extend Gitlab::Ci::Model diff --git a/app/models/ci/build_trace_section.rb b/app/models/ci/build_trace_section.rb index a4bee59c83b..8be42eb48d6 100644 --- a/app/models/ci/build_trace_section.rb +++ b/app/models/ci/build_trace_section.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class BuildTraceSection < ActiveRecord::Base + class BuildTraceSection < ApplicationRecord extend Gitlab::Ci::Model belongs_to :build, class_name: 'Ci::Build' diff --git a/app/models/ci/build_trace_section_name.rb b/app/models/ci/build_trace_section_name.rb index cbdf3c4b673..c065cfea14e 100644 --- a/app/models/ci/build_trace_section_name.rb +++ b/app/models/ci/build_trace_section_name.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class BuildTraceSectionName < ActiveRecord::Base + class BuildTraceSectionName < ApplicationRecord extend Gitlab::Ci::Model belongs_to :project diff --git a/app/models/ci/group_variable.rb b/app/models/ci/group_variable.rb index 492d1d0329e..6cada0f28e1 100644 --- a/app/models/ci/group_variable.rb +++ b/app/models/ci/group_variable.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class GroupVariable < ActiveRecord::Base + class GroupVariable < ApplicationRecord extend Gitlab::Ci::Model include HasVariable include Presentable diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb index 11c88200c37..98c2417ffdf 100644 --- a/app/models/ci/job_artifact.rb +++ b/app/models/ci/job_artifact.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class JobArtifact < ActiveRecord::Base + class JobArtifact < ApplicationRecord include AfterCommitQueue include ObjectStorage::BackgroundMove extend Gitlab::Ci::Model diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 56010e899a4..b135481b99b 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class Pipeline < ActiveRecord::Base + class Pipeline < ApplicationRecord extend Gitlab::Ci::Model include HasStatus include Importable diff --git a/app/models/ci/pipeline_schedule.rb b/app/models/ci/pipeline_schedule.rb index 1c1f203bdb2..1454b2dfb39 100644 --- a/app/models/ci/pipeline_schedule.rb +++ b/app/models/ci/pipeline_schedule.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class PipelineSchedule < ActiveRecord::Base + class PipelineSchedule < ApplicationRecord extend Gitlab::Ci::Model include Importable include IgnorableColumn diff --git a/app/models/ci/pipeline_schedule_variable.rb b/app/models/ci/pipeline_schedule_variable.rb index fbb9987cab2..be6e5e76c31 100644 --- a/app/models/ci/pipeline_schedule_variable.rb +++ b/app/models/ci/pipeline_schedule_variable.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class PipelineScheduleVariable < ActiveRecord::Base + class PipelineScheduleVariable < ApplicationRecord extend Gitlab::Ci::Model include HasVariable diff --git a/app/models/ci/pipeline_variable.rb b/app/models/ci/pipeline_variable.rb index 08514d6af4e..51a6272e1ff 100644 --- a/app/models/ci/pipeline_variable.rb +++ b/app/models/ci/pipeline_variable.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class PipelineVariable < ActiveRecord::Base + class PipelineVariable < ApplicationRecord extend Gitlab::Ci::Model include HasVariable diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index 31330d0682e..e8671fe08d3 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class Runner < ActiveRecord::Base + class Runner < ApplicationRecord extend Gitlab::Ci::Model include Gitlab::SQL::Pattern include IgnorableColumn diff --git a/app/models/ci/runner_namespace.rb b/app/models/ci/runner_namespace.rb index 22b80b98551..6903e8a21a1 100644 --- a/app/models/ci/runner_namespace.rb +++ b/app/models/ci/runner_namespace.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class RunnerNamespace < ActiveRecord::Base + class RunnerNamespace < ApplicationRecord extend Gitlab::Ci::Model belongs_to :runner, inverse_of: :runner_namespaces, validate: true diff --git a/app/models/ci/runner_project.rb b/app/models/ci/runner_project.rb index 1a718d24141..f5bd50dc5a3 100644 --- a/app/models/ci/runner_project.rb +++ b/app/models/ci/runner_project.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class RunnerProject < ActiveRecord::Base + class RunnerProject < ApplicationRecord extend Gitlab::Ci::Model belongs_to :runner, inverse_of: :runner_projects diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index 58f3fe2460a..54ef04a053a 100644 --- a/app/models/ci/stage.rb +++ b/app/models/ci/stage.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class Stage < ActiveRecord::Base + class Stage < ApplicationRecord extend Gitlab::Ci::Model include Importable include HasStatus diff --git a/app/models/ci/trigger.rb b/app/models/ci/trigger.rb index 55db42162ca..a0040fc049a 100644 --- a/app/models/ci/trigger.rb +++ b/app/models/ci/trigger.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class Trigger < ActiveRecord::Base + class Trigger < ApplicationRecord extend Gitlab::Ci::Model include IgnorableColumn diff --git a/app/models/ci/trigger_request.rb b/app/models/ci/trigger_request.rb index 0b52c690e93..5daf3dd192d 100644 --- a/app/models/ci/trigger_request.rb +++ b/app/models/ci/trigger_request.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class TriggerRequest < ActiveRecord::Base + class TriggerRequest < ApplicationRecord extend Gitlab::Ci::Model belongs_to :trigger diff --git a/app/models/ci/variable.rb b/app/models/ci/variable.rb index 524d79014f8..579d3a086d7 100644 --- a/app/models/ci/variable.rb +++ b/app/models/ci/variable.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class Variable < ActiveRecord::Base + class Variable < ApplicationRecord extend Gitlab::Ci::Model include HasVariable include Presentable diff --git a/app/models/clusters/applications/helm.rb b/app/models/clusters/applications/helm.rb index 423071ec024..71aff00077d 100644 --- a/app/models/clusters/applications/helm.rb +++ b/app/models/clusters/applications/helm.rb @@ -4,7 +4,7 @@ require 'openssl' module Clusters module Applications - class Helm < ActiveRecord::Base + class Helm < ApplicationRecord self.table_name = 'clusters_applications_helm' attr_encrypted :ca_key, diff --git a/app/models/clusters/applications/ingress.rb b/app/models/clusters/applications/ingress.rb index bd0286ee3f9..e5eacdc6b9f 100644 --- a/app/models/clusters/applications/ingress.rb +++ b/app/models/clusters/applications/ingress.rb @@ -2,7 +2,7 @@ module Clusters module Applications - class Ingress < ActiveRecord::Base + class Ingress < ApplicationRecord VERSION = '0.23.0'.freeze self.table_name = 'clusters_applications_ingress' diff --git a/app/models/clusters/applications/jupyter.rb b/app/models/clusters/applications/jupyter.rb index e43a0fd1786..a9751e1bf70 100644 --- a/app/models/clusters/applications/jupyter.rb +++ b/app/models/clusters/applications/jupyter.rb @@ -2,7 +2,7 @@ module Clusters module Applications - class Jupyter < ActiveRecord::Base + class Jupyter < ApplicationRecord VERSION = 'v0.6'.freeze self.table_name = 'clusters_applications_jupyter' diff --git a/app/models/clusters/applications/knative.rb b/app/models/clusters/applications/knative.rb index a79a97576d1..d094ff7a26b 100644 --- a/app/models/clusters/applications/knative.rb +++ b/app/models/clusters/applications/knative.rb @@ -2,7 +2,7 @@ module Clusters module Applications - class Knative < ActiveRecord::Base + class Knative < ApplicationRecord VERSION = '0.1.3'.freeze REPOSITORY = 'https://storage.googleapis.com/triggermesh-charts'.freeze diff --git a/app/models/clusters/applications/prometheus.rb b/app/models/clusters/applications/prometheus.rb index 46d0388a464..d496e8f0820 100644 --- a/app/models/clusters/applications/prometheus.rb +++ b/app/models/clusters/applications/prometheus.rb @@ -2,7 +2,7 @@ module Clusters module Applications - class Prometheus < ActiveRecord::Base + class Prometheus < ApplicationRecord include PrometheusAdapter VERSION = '6.7.3'.freeze diff --git a/app/models/clusters/applications/runner.rb b/app/models/clusters/applications/runner.rb index b311f5e0617..34ef67a07b1 100644 --- a/app/models/clusters/applications/runner.rb +++ b/app/models/clusters/applications/runner.rb @@ -2,7 +2,7 @@ module Clusters module Applications - class Runner < ActiveRecord::Base + class Runner < ApplicationRecord VERSION = '0.1.35'.freeze self.table_name = 'clusters_applications_runners' diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb index 0ba056e57d4..a5748006ec8 100644 --- a/app/models/clusters/cluster.rb +++ b/app/models/clusters/cluster.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Clusters - class Cluster < ActiveRecord::Base + class Cluster < ApplicationRecord include Presentable include Gitlab::Utils::StrongMemoize diff --git a/app/models/clusters/group.rb b/app/models/clusters/group.rb index 2b08a9e47f0..27f39b53579 100644 --- a/app/models/clusters/group.rb +++ b/app/models/clusters/group.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Clusters - class Group < ActiveRecord::Base + class Group < ApplicationRecord self.table_name = 'cluster_groups' belongs_to :cluster, class_name: 'Clusters::Cluster' diff --git a/app/models/clusters/kubernetes_namespace.rb b/app/models/clusters/kubernetes_namespace.rb index ac7f9193b87..d449e1c7b1f 100644 --- a/app/models/clusters/kubernetes_namespace.rb +++ b/app/models/clusters/kubernetes_namespace.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Clusters - class KubernetesNamespace < ActiveRecord::Base + class KubernetesNamespace < ApplicationRecord include Gitlab::Kubernetes self.table_name = 'clusters_kubernetes_namespaces' diff --git a/app/models/clusters/platforms/kubernetes.rb b/app/models/clusters/platforms/kubernetes.rb index ea02ae6c9d8..84a73f86870 100644 --- a/app/models/clusters/platforms/kubernetes.rb +++ b/app/models/clusters/platforms/kubernetes.rb @@ -2,7 +2,7 @@ module Clusters module Platforms - class Kubernetes < ActiveRecord::Base + class Kubernetes < ApplicationRecord include Gitlab::Kubernetes include ReactiveCaching include EnumWithNil diff --git a/app/models/clusters/project.rb b/app/models/clusters/project.rb index 15092b1c9d2..d2b68b3f117 100644 --- a/app/models/clusters/project.rb +++ b/app/models/clusters/project.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Clusters - class Project < ActiveRecord::Base + class Project < ApplicationRecord self.table_name = 'cluster_projects' belongs_to :cluster, class_name: 'Clusters::Cluster' diff --git a/app/models/clusters/providers/gcp.rb b/app/models/clusters/providers/gcp.rb index 16b59cd9d14..390748bf252 100644 --- a/app/models/clusters/providers/gcp.rb +++ b/app/models/clusters/providers/gcp.rb @@ -2,7 +2,7 @@ module Clusters module Providers - class Gcp < ActiveRecord::Base + class Gcp < ApplicationRecord self.table_name = 'cluster_providers_gcp' belongs_to :cluster, inverse_of: :provider_gcp, class_name: 'Clusters::Cluster' diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 755f8bd4d06..4cd0152a59b 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CommitStatus < ActiveRecord::Base +class CommitStatus < ApplicationRecord include HasStatus include Importable include AfterCommitQueue diff --git a/app/models/container_repository.rb b/app/models/container_repository.rb index 2c08a8e1acf..04e2f39e4d5 100644 --- a/app/models/container_repository.rb +++ b/app/models/container_repository.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ContainerRepository < ActiveRecord::Base +class ContainerRepository < ApplicationRecord belongs_to :project validates :name, length: { minimum: 0, allow_nil: false } diff --git a/app/models/conversational_development_index/metric.rb b/app/models/conversational_development_index/metric.rb index c54537572d6..b91123be87e 100644 --- a/app/models/conversational_development_index/metric.rb +++ b/app/models/conversational_development_index/metric.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module ConversationalDevelopmentIndex - class Metric < ActiveRecord::Base + class Metric < ApplicationRecord include Presentable self.table_name = 'conversational_development_index_metrics' diff --git a/app/models/deploy_keys_project.rb b/app/models/deploy_keys_project.rb index 71fd02fac86..15906ed8e06 100644 --- a/app/models/deploy_keys_project.rb +++ b/app/models/deploy_keys_project.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class DeployKeysProject < ActiveRecord::Base +class DeployKeysProject < ApplicationRecord belongs_to :project belongs_to :deploy_key, inverse_of: :deploy_keys_projects diff --git a/app/models/deploy_token.rb b/app/models/deploy_token.rb index e3524305346..b0e570f52ba 100644 --- a/app/models/deploy_token.rb +++ b/app/models/deploy_token.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class DeployToken < ActiveRecord::Base +class DeployToken < ApplicationRecord include Expirable include TokenAuthenticatable include PolicyActor diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 83434276995..a2408360dce 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Deployment < ActiveRecord::Base +class Deployment < ApplicationRecord include AtomicInternalId include IidRoutes include AfterCommitQueue diff --git a/app/models/email.rb b/app/models/email.rb index b6a977dfa22..c5d6bcab9d8 100644 --- a/app/models/email.rb +++ b/app/models/email.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Email < ActiveRecord::Base +class Email < ApplicationRecord include Sortable include Gitlab::SQL::Pattern diff --git a/app/models/environment.rb b/app/models/environment.rb index 934828946b9..5a076f529ba 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Environment < ActiveRecord::Base +class Environment < ApplicationRecord # Used to generate random suffixes for the slug LETTERS = 'a'..'z' NUMBERS = '0'..'9' diff --git a/app/models/epic.rb b/app/models/epic.rb index ccd10593434..3693db1de33 100644 --- a/app/models/epic.rb +++ b/app/models/epic.rb @@ -2,7 +2,7 @@ # Placeholder class for model that is implemented in EE # It reserves '&' as a reference prefix, but the table does not exists in CE -class Epic < ActiveRecord::Base +class Epic < ApplicationRecord def self.link_reference_pattern nil end diff --git a/app/models/event.rb b/app/models/event.rb index 2e690f8c013..df2024c7586 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Event < ActiveRecord::Base +class Event < ApplicationRecord include Sortable include IgnorableColumn include FromUnion diff --git a/app/models/fork_network.rb b/app/models/fork_network.rb index 1b9bf93cbbc..0323a8d222a 100644 --- a/app/models/fork_network.rb +++ b/app/models/fork_network.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ForkNetwork < ActiveRecord::Base +class ForkNetwork < ApplicationRecord belongs_to :root_project, class_name: 'Project' has_many :fork_network_members has_many :projects, through: :fork_network_members diff --git a/app/models/fork_network_member.rb b/app/models/fork_network_member.rb index 36c66f21b0b..f18c306cf91 100644 --- a/app/models/fork_network_member.rb +++ b/app/models/fork_network_member.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ForkNetworkMember < ActiveRecord::Base +class ForkNetworkMember < ApplicationRecord belongs_to :fork_network belongs_to :project belongs_to :forked_from_project, class_name: 'Project' diff --git a/app/models/gpg_key.rb b/app/models/gpg_key.rb index 077afffd358..116beac5c2a 100644 --- a/app/models/gpg_key.rb +++ b/app/models/gpg_key.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class GpgKey < ActiveRecord::Base +class GpgKey < ApplicationRecord KEY_PREFIX = '-----BEGIN PGP PUBLIC KEY BLOCK-----'.freeze KEY_SUFFIX = '-----END PGP PUBLIC KEY BLOCK-----'.freeze diff --git a/app/models/gpg_key_subkey.rb b/app/models/gpg_key_subkey.rb index 440b588bc78..110bf451136 100644 --- a/app/models/gpg_key_subkey.rb +++ b/app/models/gpg_key_subkey.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class GpgKeySubkey < ActiveRecord::Base +class GpgKeySubkey < ApplicationRecord include ShaAttribute sha_attribute :keyid diff --git a/app/models/gpg_signature.rb b/app/models/gpg_signature.rb index 0816778deae..29b01d8b6f0 100644 --- a/app/models/gpg_signature.rb +++ b/app/models/gpg_signature.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class GpgSignature < ActiveRecord::Base +class GpgSignature < ApplicationRecord include ShaAttribute sha_attribute :commit_sha diff --git a/app/models/group_custom_attribute.rb b/app/models/group_custom_attribute.rb index 22f14885657..5ac6e5f2550 100644 --- a/app/models/group_custom_attribute.rb +++ b/app/models/group_custom_attribute.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class GroupCustomAttribute < ActiveRecord::Base +class GroupCustomAttribute < ApplicationRecord belongs_to :group validates :group, :key, :value, presence: true diff --git a/app/models/hooks/web_hook.rb b/app/models/hooks/web_hook.rb index b2fb79bc7ed..a4a772a2144 100644 --- a/app/models/hooks/web_hook.rb +++ b/app/models/hooks/web_hook.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class WebHook < ActiveRecord::Base +class WebHook < ApplicationRecord include Sortable attr_encrypted :token, diff --git a/app/models/hooks/web_hook_log.rb b/app/models/hooks/web_hook_log.rb index 2d9f7594e8c..cfb1f3ec63b 100644 --- a/app/models/hooks/web_hook_log.rb +++ b/app/models/hooks/web_hook_log.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class WebHookLog < ActiveRecord::Base +class WebHookLog < ApplicationRecord belongs_to :web_hook serialize :request_headers, Hash # rubocop:disable Cop/ActiveRecordSerialize diff --git a/app/models/identity.rb b/app/models/identity.rb index f5a13dbd6f2..38326dfe09c 100644 --- a/app/models/identity.rb +++ b/app/models/identity.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Identity < ActiveRecord::Base +class Identity < ApplicationRecord def self.uniqueness_scope :provider end diff --git a/app/models/import_export_upload.rb b/app/models/import_export_upload.rb index f0cc5aafcd4..60f5491849a 100644 --- a/app/models/import_export_upload.rb +++ b/app/models/import_export_upload.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ImportExportUpload < ActiveRecord::Base +class ImportExportUpload < ApplicationRecord include WithUploads include ObjectStorage::BackgroundMove diff --git a/app/models/internal_id.rb b/app/models/internal_id.rb index e7168d49db9..163022b585d 100644 --- a/app/models/internal_id.rb +++ b/app/models/internal_id.rb @@ -15,7 +15,7 @@ # In order to leverage InternalId for other usages, the idea is to # * Add `usage` value to enum # * (Optionally) add columns to `internal_ids` if needed for scope. -class InternalId < ActiveRecord::Base +class InternalId < ApplicationRecord belongs_to :project belongs_to :namespace diff --git a/app/models/issue.rb b/app/models/issue.rb index 0de5e434b02..af992f4c8bc 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -2,7 +2,7 @@ require 'carrierwave/orm/activerecord' -class Issue < ActiveRecord::Base +class Issue < ApplicationRecord include AtomicInternalId include IidRoutes include Issuable diff --git a/app/models/issue/metrics.rb b/app/models/issue/metrics.rb index 0f5ee957ec9..8010cbc3d78 100644 --- a/app/models/issue/metrics.rb +++ b/app/models/issue/metrics.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Issue::Metrics < ActiveRecord::Base +class Issue::Metrics < ApplicationRecord belongs_to :issue def record! diff --git a/app/models/issue_assignee.rb b/app/models/issue_assignee.rb index 400c0256945..fbd9be1fb43 100644 --- a/app/models/issue_assignee.rb +++ b/app/models/issue_assignee.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class IssueAssignee < ActiveRecord::Base +class IssueAssignee < ApplicationRecord belongs_to :issue belongs_to :assignee, class_name: "User", foreign_key: :user_id end diff --git a/app/models/key.rb b/app/models/key.rb index 8f93418b88b..b097be8cc89 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -2,7 +2,7 @@ require 'digest/md5' -class Key < ActiveRecord::Base +class Key < ApplicationRecord include AfterCommitQueue include Sortable diff --git a/app/models/label.rb b/app/models/label.rb index 165e4a8f3e5..b50beaf5fa2 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Label < ActiveRecord::Base +class Label < ApplicationRecord include CacheMarkdownField include Referable include Subscribable diff --git a/app/models/label_link.rb b/app/models/label_link.rb index 1d93a55e8e9..ffc0afd8e85 100644 --- a/app/models/label_link.rb +++ b/app/models/label_link.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class LabelLink < ActiveRecord::Base +class LabelLink < ApplicationRecord include Importable belongs_to :target, polymorphic: true, inverse_of: :label_links # rubocop:disable Cop/PolymorphicAssociations diff --git a/app/models/label_priority.rb b/app/models/label_priority.rb index 8ed8bb7577f..8f8f36efbfe 100644 --- a/app/models/label_priority.rb +++ b/app/models/label_priority.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class LabelPriority < ActiveRecord::Base +class LabelPriority < ApplicationRecord belongs_to :project belongs_to :label diff --git a/app/models/lfs_file_lock.rb b/app/models/lfs_file_lock.rb index 431d37e12e9..624b1d02e1a 100644 --- a/app/models/lfs_file_lock.rb +++ b/app/models/lfs_file_lock.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class LfsFileLock < ActiveRecord::Base +class LfsFileLock < ApplicationRecord belongs_to :project belongs_to :user diff --git a/app/models/lfs_object.rb b/app/models/lfs_object.rb index 69c563545bb..e1aac691a64 100644 --- a/app/models/lfs_object.rb +++ b/app/models/lfs_object.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class LfsObject < ActiveRecord::Base +class LfsObject < ApplicationRecord include AfterCommitQueue include ObjectStorage::BackgroundMove diff --git a/app/models/lfs_objects_project.rb b/app/models/lfs_objects_project.rb index 353602800d7..f9afb18c1d7 100644 --- a/app/models/lfs_objects_project.rb +++ b/app/models/lfs_objects_project.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class LfsObjectsProject < ActiveRecord::Base +class LfsObjectsProject < ApplicationRecord belongs_to :project belongs_to :lfs_object diff --git a/app/models/list.rb b/app/models/list.rb index 029685be927..d41be882480 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class List < ActiveRecord::Base +class List < ApplicationRecord belongs_to :board belongs_to :label diff --git a/app/models/member.rb b/app/models/member.rb index 0696ea46c8b..ca3ef2df306 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Member < ActiveRecord::Base +class Member < ApplicationRecord include AfterCommitQueue include Sortable include Importable diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index df5678ec2f1..fe1ba299b0c 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class MergeRequest < ActiveRecord::Base +class MergeRequest < ApplicationRecord include AtomicInternalId include IidRoutes include Issuable diff --git a/app/models/merge_request/metrics.rb b/app/models/merge_request/metrics.rb index 65e94a97b0a..05f8e18a2c1 100644 --- a/app/models/merge_request/metrics.rb +++ b/app/models/merge_request/metrics.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class MergeRequest::Metrics < ActiveRecord::Base +class MergeRequest::Metrics < ApplicationRecord belongs_to :merge_request belongs_to :pipeline, class_name: 'Ci::Pipeline', foreign_key: :pipeline_id belongs_to :latest_closed_by, class_name: 'User' diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index 74583af1a29..62a056608bc 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class MergeRequestDiff < ActiveRecord::Base +class MergeRequestDiff < ApplicationRecord include Sortable include Importable include ManualInverseAssociation diff --git a/app/models/merge_request_diff_commit.rb b/app/models/merge_request_diff_commit.rb index 4ad3690512d..b897bbc8cf5 100644 --- a/app/models/merge_request_diff_commit.rb +++ b/app/models/merge_request_diff_commit.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class MergeRequestDiffCommit < ActiveRecord::Base +class MergeRequestDiffCommit < ApplicationRecord include ShaAttribute belongs_to :merge_request_diff diff --git a/app/models/merge_request_diff_file.rb b/app/models/merge_request_diff_file.rb index a9f110bec5c..4dd663837ee 100644 --- a/app/models/merge_request_diff_file.rb +++ b/app/models/merge_request_diff_file.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class MergeRequestDiffFile < ActiveRecord::Base +class MergeRequestDiffFile < ApplicationRecord include Gitlab::EncodingHelper include DiffFile diff --git a/app/models/merge_requests_closing_issues.rb b/app/models/merge_requests_closing_issues.rb index 242b65bedc0..61af50841ee 100644 --- a/app/models/merge_requests_closing_issues.rb +++ b/app/models/merge_requests_closing_issues.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class MergeRequestsClosingIssues < ActiveRecord::Base +class MergeRequestsClosingIssues < ApplicationRecord belongs_to :merge_request belongs_to :issue diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 3cc8e2c44bb..aef34e306b8 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Milestone < ActiveRecord::Base +class Milestone < ApplicationRecord # Represents a "No Milestone" state used for filtering Issues and Merge # Requests that have no milestone assigned. MilestoneStruct = Struct.new(:title, :name, :id) diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 4a6627d3ca1..204f996d7c1 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Namespace < ActiveRecord::Base +class Namespace < ApplicationRecord include CacheMarkdownField include Sortable include Gitlab::ShellAdapter diff --git a/app/models/note.rb b/app/models/note.rb index 592efb714f3..12eaa3af8dd 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -3,7 +3,7 @@ # A note on the root of an issue, merge request, commit, or snippet. # # A note of this type is never resolvable. -class Note < ActiveRecord::Base +class Note < ApplicationRecord extend ActiveModel::Naming include Participable include Mentionable diff --git a/app/models/note_diff_file.rb b/app/models/note_diff_file.rb index 27aef7adc48..b39ec67eeb1 100644 --- a/app/models/note_diff_file.rb +++ b/app/models/note_diff_file.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class NoteDiffFile < ActiveRecord::Base +class NoteDiffFile < ApplicationRecord include DiffFile belongs_to :diff_note, inverse_of: :note_diff_file diff --git a/app/models/notification_recipient.rb b/app/models/notification_recipient.rb index 9f16eefe074..57829f2c27f 100644 --- a/app/models/notification_recipient.rb +++ b/app/models/notification_recipient.rb @@ -128,7 +128,7 @@ class NotificationRecipient :"read_#{@target.to_ability_name}" when Ci::Pipeline :read_build # We have build trace in pipeline emails - when ActiveRecord::Base + when ApplicationRecord :"read_#{@target.class.model_name.name.underscore}" else nil diff --git a/app/models/notification_setting.rb b/app/models/notification_setting.rb index 1600acfc575..031624426aa 100644 --- a/app/models/notification_setting.rb +++ b/app/models/notification_setting.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class NotificationSetting < ActiveRecord::Base +class NotificationSetting < ApplicationRecord include IgnorableColumn ignore_column :events diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb index 7a33ade826b..82901ceec01 100644 --- a/app/models/pages_domain.rb +++ b/app/models/pages_domain.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class PagesDomain < ActiveRecord::Base +class PagesDomain < ApplicationRecord VERIFICATION_KEY = 'gitlab-pages-verification-code'.freeze VERIFICATION_THRESHOLD = 3.days.freeze diff --git a/app/models/personal_access_token.rb b/app/models/personal_access_token.rb index 73a58f2420e..201e1e6e1f8 100644 --- a/app/models/personal_access_token.rb +++ b/app/models/personal_access_token.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class PersonalAccessToken < ActiveRecord::Base +class PersonalAccessToken < ApplicationRecord include Expirable include TokenAuthenticatable add_authentication_token_field :token, digest: true, fallback: true diff --git a/app/models/pool_repository.rb b/app/models/pool_repository.rb index 8ef74539209..31b7d211014 100644 --- a/app/models/pool_repository.rb +++ b/app/models/pool_repository.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class PoolRepository < ActiveRecord::Base +class PoolRepository < ApplicationRecord POOL_PREFIX = '@pools' belongs_to :shard diff --git a/app/models/postgresql/replication_slot.rb b/app/models/postgresql/replication_slot.rb index e264fe88e47..74ccf23cf69 100644 --- a/app/models/postgresql/replication_slot.rb +++ b/app/models/postgresql/replication_slot.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Postgresql - class ReplicationSlot < ActiveRecord::Base + class ReplicationSlot < ApplicationRecord self.table_name = 'pg_replication_slots' # Returns true if there are any replication slots in use. diff --git a/app/models/programming_language.rb b/app/models/programming_language.rb index 0e667dac21e..dc06d6ad132 100644 --- a/app/models/programming_language.rb +++ b/app/models/programming_language.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ProgrammingLanguage < ActiveRecord::Base +class ProgrammingLanguage < ApplicationRecord validates :name, presence: true validates :color, allow_blank: false, color: true end diff --git a/app/models/project.rb b/app/models/project.rb index d87fc1e4b86..9f46008af8a 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2,7 +2,7 @@ require 'carrierwave/orm/activerecord' -class Project < ActiveRecord::Base +class Project < ApplicationRecord include Gitlab::ConfigHelper include Gitlab::ShellAdapter include Gitlab::VisibilityLevel diff --git a/app/models/project_authorization.rb b/app/models/project_authorization.rb index 2c590008db2..f95d3ab54e2 100644 --- a/app/models/project_authorization.rb +++ b/app/models/project_authorization.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ProjectAuthorization < ActiveRecord::Base +class ProjectAuthorization < ApplicationRecord include FromUnion belongs_to :user diff --git a/app/models/project_auto_devops.rb b/app/models/project_auto_devops.rb index 2253ad7b543..537422d6155 100644 --- a/app/models/project_auto_devops.rb +++ b/app/models/project_auto_devops.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ProjectAutoDevops < ActiveRecord::Base +class ProjectAutoDevops < ApplicationRecord belongs_to :project enum deploy_strategy: { diff --git a/app/models/project_ci_cd_setting.rb b/app/models/project_ci_cd_setting.rb index 1dad235cc2b..1414164b703 100644 --- a/app/models/project_ci_cd_setting.rb +++ b/app/models/project_ci_cd_setting.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ProjectCiCdSetting < ActiveRecord::Base +class ProjectCiCdSetting < ApplicationRecord belongs_to :project, inverse_of: :ci_cd_settings # The version of the schema that first introduced this model/table. diff --git a/app/models/project_custom_attribute.rb b/app/models/project_custom_attribute.rb index 4e767cb3b26..b0da586988a 100644 --- a/app/models/project_custom_attribute.rb +++ b/app/models/project_custom_attribute.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ProjectCustomAttribute < ActiveRecord::Base +class ProjectCustomAttribute < ApplicationRecord belongs_to :project validates :project, :key, :value, presence: true diff --git a/app/models/project_deploy_token.rb b/app/models/project_deploy_token.rb index 719c492a1ff..a55667496fb 100644 --- a/app/models/project_deploy_token.rb +++ b/app/models/project_deploy_token.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ProjectDeployToken < ActiveRecord::Base +class ProjectDeployToken < ApplicationRecord belongs_to :project belongs_to :deploy_token, inverse_of: :project_deploy_tokens diff --git a/app/models/project_feature.rb b/app/models/project_feature.rb index 39f2b8fe0de..194da079e57 100644 --- a/app/models/project_feature.rb +++ b/app/models/project_feature.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ProjectFeature < ActiveRecord::Base +class ProjectFeature < ApplicationRecord # == Project features permissions # # Grants access level to project tools diff --git a/app/models/project_group_link.rb b/app/models/project_group_link.rb index bc3759142ae..58b555c3581 100644 --- a/app/models/project_group_link.rb +++ b/app/models/project_group_link.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ProjectGroupLink < ActiveRecord::Base +class ProjectGroupLink < ApplicationRecord include Expirable GUEST = 10 diff --git a/app/models/project_import_data.rb b/app/models/project_import_data.rb index 2c3080c6d8d..270d7cc46a4 100644 --- a/app/models/project_import_data.rb +++ b/app/models/project_import_data.rb @@ -2,7 +2,7 @@ require 'carrierwave/orm/activerecord' -class ProjectImportData < ActiveRecord::Base +class ProjectImportData < ApplicationRecord belongs_to :project, inverse_of: :import_data attr_encrypted :credentials, key: Settings.attr_encrypted_db_key_base, diff --git a/app/models/project_import_state.rb b/app/models/project_import_state.rb index 7126bb66d80..098e8fab06b 100644 --- a/app/models/project_import_state.rb +++ b/app/models/project_import_state.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ProjectImportState < ActiveRecord::Base +class ProjectImportState < ApplicationRecord include AfterCommitQueue self.table_name = "project_mirror_data" diff --git a/app/models/project_statistics.rb b/app/models/project_statistics.rb index 781a197d56f..c020e72908c 100644 --- a/app/models/project_statistics.rb +++ b/app/models/project_statistics.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ProjectStatistics < ActiveRecord::Base +class ProjectStatistics < ApplicationRecord belongs_to :project belongs_to :namespace diff --git a/app/models/prometheus_metric.rb b/app/models/prometheus_metric.rb index ce2db9cb44c..8c6f324cbb3 100644 --- a/app/models/prometheus_metric.rb +++ b/app/models/prometheus_metric.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class PrometheusMetric < ActiveRecord::Base +class PrometheusMetric < ApplicationRecord belongs_to :project, validate: true, inverse_of: :prometheus_metrics enum group: { diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb index 6c1073265a1..edaf9a56532 100644 --- a/app/models/protected_branch.rb +++ b/app/models/protected_branch.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ProtectedBranch < ActiveRecord::Base +class ProtectedBranch < ApplicationRecord include Gitlab::ShellAdapter include ProtectedRef diff --git a/app/models/protected_branch/merge_access_level.rb b/app/models/protected_branch/merge_access_level.rb index b0d5c64e931..de240e40316 100644 --- a/app/models/protected_branch/merge_access_level.rb +++ b/app/models/protected_branch/merge_access_level.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -class ProtectedBranch::MergeAccessLevel < ActiveRecord::Base +class ProtectedBranch::MergeAccessLevel < ApplicationRecord include ProtectedBranchAccess end diff --git a/app/models/protected_branch/push_access_level.rb b/app/models/protected_branch/push_access_level.rb index b2a88229853..bde1d29ad7f 100644 --- a/app/models/protected_branch/push_access_level.rb +++ b/app/models/protected_branch/push_access_level.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -class ProtectedBranch::PushAccessLevel < ActiveRecord::Base +class ProtectedBranch::PushAccessLevel < ApplicationRecord include ProtectedBranchAccess end diff --git a/app/models/protected_tag.rb b/app/models/protected_tag.rb index 94746141945..722bacaea12 100644 --- a/app/models/protected_tag.rb +++ b/app/models/protected_tag.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ProtectedTag < ActiveRecord::Base +class ProtectedTag < ApplicationRecord include Gitlab::ShellAdapter include ProtectedRef diff --git a/app/models/protected_tag/create_access_level.rb b/app/models/protected_tag/create_access_level.rb index b06e55fb5dd..9fcfa7646a2 100644 --- a/app/models/protected_tag/create_access_level.rb +++ b/app/models/protected_tag/create_access_level.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ProtectedTag::CreateAccessLevel < ActiveRecord::Base +class ProtectedTag::CreateAccessLevel < ApplicationRecord include ProtectedTagAccess def check_access(user) diff --git a/app/models/push_event_payload.rb b/app/models/push_event_payload.rb index c7769edf055..537859ec7b7 100644 --- a/app/models/push_event_payload.rb +++ b/app/models/push_event_payload.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class PushEventPayload < ActiveRecord::Base +class PushEventPayload < ApplicationRecord include ShaAttribute belongs_to :event, inverse_of: :push_event_payload diff --git a/app/models/redirect_route.rb b/app/models/redirect_route.rb index c6bd4bb6dfa..2e4769364c6 100644 --- a/app/models/redirect_route.rb +++ b/app/models/redirect_route.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class RedirectRoute < ActiveRecord::Base +class RedirectRoute < ApplicationRecord belongs_to :source, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations validates :source, presence: true diff --git a/app/models/release.rb b/app/models/release.rb index cba80ad30ca..09a7f565705 100644 --- a/app/models/release.rb +++ b/app/models/release.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Release < ActiveRecord::Base +class Release < ApplicationRecord include CacheMarkdownField cache_markdown_field :description diff --git a/app/models/remote_mirror.rb b/app/models/remote_mirror.rb index c1f53b5da4f..02818df54e5 100644 --- a/app/models/remote_mirror.rb +++ b/app/models/remote_mirror.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class RemoteMirror < ActiveRecord::Base +class RemoteMirror < ApplicationRecord include AfterCommitQueue PROTECTED_BACKOFF_DELAY = 1.minute diff --git a/app/models/repository_language.rb b/app/models/repository_language.rb index b18142a2ac4..e6867f905e2 100644 --- a/app/models/repository_language.rb +++ b/app/models/repository_language.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class RepositoryLanguage < ActiveRecord::Base +class RepositoryLanguage < ApplicationRecord belongs_to :project belongs_to :programming_language diff --git a/app/models/resource_label_event.rb b/app/models/resource_label_event.rb index 3fd96b9dc18..f2c7cb6a65d 100644 --- a/app/models/resource_label_event.rb +++ b/app/models/resource_label_event.rb @@ -2,7 +2,7 @@ # This model is not used yet, it will be used for: # https://gitlab.com/gitlab-org/gitlab-ce/issues/48483 -class ResourceLabelEvent < ActiveRecord::Base +class ResourceLabelEvent < ApplicationRecord include Importable include Gitlab::Utils::StrongMemoize include CacheMarkdownField diff --git a/app/models/route.rb b/app/models/route.rb index 4b23dfa5778..7e3db54d4fe 100644 --- a/app/models/route.rb +++ b/app/models/route.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Route < ActiveRecord::Base +class Route < ApplicationRecord include CaseSensitivity belongs_to :source, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations diff --git a/app/models/sent_notification.rb b/app/models/sent_notification.rb index e65b3df0fb6..ea318b821e7 100644 --- a/app/models/sent_notification.rb +++ b/app/models/sent_notification.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class SentNotification < ActiveRecord::Base +class SentNotification < ApplicationRecord serialize :position, Gitlab::Diff::Position # rubocop:disable Cop/ActiveRecordSerialize belongs_to :project diff --git a/app/models/service.rb b/app/models/service.rb index 5b8bf6e7cf0..6d79ebbea8f 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -2,7 +2,7 @@ # To add new service you should build a class inherited from Service # and implement a set of methods -class Service < ActiveRecord::Base +class Service < ApplicationRecord include Sortable include Importable include ProjectServicesLoggable diff --git a/app/models/shard.rb b/app/models/shard.rb index 2fa22bd040c..cf4394dfbda 100644 --- a/app/models/shard.rb +++ b/app/models/shard.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Shard < ActiveRecord::Base +class Shard < ApplicationRecord # Store shard names from the configuration file in the database. This is not a # list of active shards - we just want to assign an immutable, unique ID to # every shard name for easy indexing / referencing. diff --git a/app/models/site_statistic.rb b/app/models/site_statistic.rb index 3a7912ed53a..2d144c99ded 100644 --- a/app/models/site_statistic.rb +++ b/app/models/site_statistic.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class SiteStatistic < ActiveRecord::Base +class SiteStatistic < ApplicationRecord # prevents the creation of multiple rows default_value_for :id, 1 diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 11856b55902..5cdfe6e0441 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Snippet < ActiveRecord::Base +class Snippet < ApplicationRecord include Gitlab::VisibilityLevel include Redactable include CacheMarkdownField diff --git a/app/models/spam_log.rb b/app/models/spam_log.rb index ef3f974b959..5b9ece8373f 100644 --- a/app/models/spam_log.rb +++ b/app/models/spam_log.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class SpamLog < ActiveRecord::Base +class SpamLog < ApplicationRecord belongs_to :user validates :user, presence: true diff --git a/app/models/subscription.rb b/app/models/subscription.rb index 0f6ee0ddf7e..24a2b8b5167 100644 --- a/app/models/subscription.rb +++ b/app/models/subscription.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Subscription < ActiveRecord::Base +class Subscription < ApplicationRecord belongs_to :user belongs_to :project belongs_to :subscribable, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations diff --git a/app/models/system_note_metadata.rb b/app/models/system_note_metadata.rb index d555ebe5322..55da37c9545 100644 --- a/app/models/system_note_metadata.rb +++ b/app/models/system_note_metadata.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class SystemNoteMetadata < ActiveRecord::Base +class SystemNoteMetadata < ApplicationRecord # These notes's action text might contain a reference that is external. # We should always force a deep validation upon references that are found # in this note type. diff --git a/app/models/term_agreement.rb b/app/models/term_agreement.rb index 9b3c8ac68bd..a4a9dc10282 100644 --- a/app/models/term_agreement.rb +++ b/app/models/term_agreement.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class TermAgreement < ActiveRecord::Base +class TermAgreement < ApplicationRecord belongs_to :term, class_name: 'ApplicationSetting::Term' belongs_to :user diff --git a/app/models/timelog.rb b/app/models/timelog.rb index e04c644a53a..048134fbf04 100644 --- a/app/models/timelog.rb +++ b/app/models/timelog.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Timelog < ActiveRecord::Base +class Timelog < ApplicationRecord validates :time_spent, :user, presence: true validate :issuable_id_is_present diff --git a/app/models/todo.rb b/app/models/todo.rb index 7b64615f699..3bb3d810d68 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Todo < ActiveRecord::Base +class Todo < ApplicationRecord include Sortable include FromUnion diff --git a/app/models/trending_project.rb b/app/models/trending_project.rb index 7b22e8cb760..810dee672b2 100644 --- a/app/models/trending_project.rb +++ b/app/models/trending_project.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class TrendingProject < ActiveRecord::Base +class TrendingProject < ApplicationRecord belongs_to :project # The number of months to include in the trending calculation. diff --git a/app/models/u2f_registration.rb b/app/models/u2f_registration.rb index 37598173fd1..b4645462314 100644 --- a/app/models/u2f_registration.rb +++ b/app/models/u2f_registration.rb @@ -2,7 +2,7 @@ # Registration information for U2F (universal 2nd factor) devices, like Yubikeys -class U2fRegistration < ActiveRecord::Base +class U2fRegistration < ApplicationRecord belongs_to :user def self.register(user, app_id, params, challenges) diff --git a/app/models/upload.rb b/app/models/upload.rb index e01e9c6a4f0..95507b5364a 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Upload < ActiveRecord::Base +class Upload < ApplicationRecord # Upper limit for foreground checksum processing CHECKSUM_THRESHOLD = 100.megabytes diff --git a/app/models/user.rb b/app/models/user.rb index a400058e87e..9ca98e9684d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,7 +2,7 @@ require 'carrierwave/orm/activerecord' -class User < ActiveRecord::Base +class User < ApplicationRecord extend Gitlab::ConfigHelper include Gitlab::ConfigHelper @@ -415,7 +415,7 @@ class User < ActiveRecord::Base fuzzy_arel_match(:name, query, lower_exact_match: true) .or(fuzzy_arel_match(:username, query, lower_exact_match: true)) .or(arel_table[:email].eq(query)) - ).reorder(order % { query: ActiveRecord::Base.connection.quote(query) }, :name) + ).reorder(order % { query: ApplicationRecord.connection.quote(query) }, :name) end # Limits the result set to users _not_ in the given query/list of IDs. diff --git a/app/models/user_agent_detail.rb b/app/models/user_agent_detail.rb index e2b2e7f1df9..fea1fce3c8d 100644 --- a/app/models/user_agent_detail.rb +++ b/app/models/user_agent_detail.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class UserAgentDetail < ActiveRecord::Base +class UserAgentDetail < ApplicationRecord belongs_to :subject, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations validates :user_agent, :ip_address, :subject_id, :subject_type, presence: true diff --git a/app/models/user_callout.rb b/app/models/user_callout.rb index 1cd05cf3aac..c3b2cbcb349 100644 --- a/app/models/user_callout.rb +++ b/app/models/user_callout.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class UserCallout < ActiveRecord::Base +class UserCallout < ApplicationRecord belongs_to :user enum feature_name: { diff --git a/app/models/user_custom_attribute.rb b/app/models/user_custom_attribute.rb index e0ffe8ebbfd..727975c3f6e 100644 --- a/app/models/user_custom_attribute.rb +++ b/app/models/user_custom_attribute.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class UserCustomAttribute < ActiveRecord::Base +class UserCustomAttribute < ApplicationRecord belongs_to :user validates :user_id, :key, :value, presence: true diff --git a/app/models/user_interacted_project.rb b/app/models/user_interacted_project.rb index ae6778e49be..2560f9f44d2 100644 --- a/app/models/user_interacted_project.rb +++ b/app/models/user_interacted_project.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class UserInteractedProject < ActiveRecord::Base +class UserInteractedProject < ApplicationRecord belongs_to :user belongs_to :project diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index 32d0407800f..282b192167f 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class UserPreference < ActiveRecord::Base +class UserPreference < ApplicationRecord # We could use enums, but Rails 4 doesn't support multiple # enum options with same name for multiple fields, also it creates # extra methods that aren't really needed here. diff --git a/app/models/user_status.rb b/app/models/user_status.rb index 2bbb0c59ac1..6ced4f56823 100644 --- a/app/models/user_status.rb +++ b/app/models/user_status.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class UserStatus < ActiveRecord::Base +class UserStatus < ApplicationRecord include CacheMarkdownField self.primary_key = :user_id diff --git a/app/models/user_synced_attributes_metadata.rb b/app/models/user_synced_attributes_metadata.rb index 7115262942d..5aacf11b1cb 100644 --- a/app/models/user_synced_attributes_metadata.rb +++ b/app/models/user_synced_attributes_metadata.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class UserSyncedAttributesMetadata < ActiveRecord::Base +class UserSyncedAttributesMetadata < ApplicationRecord belongs_to :user validates :user, presence: true diff --git a/app/models/users_star_project.rb b/app/models/users_star_project.rb index bdaf58ae1c1..9be6bd2e6f3 100644 --- a/app/models/users_star_project.rb +++ b/app/models/users_star_project.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class UsersStarProject < ActiveRecord::Base +class UsersStarProject < ApplicationRecord belongs_to :project, counter_cache: :star_count, touch: true belongs_to :user diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index e32e262ac31..176fd9f1001 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -206,7 +206,7 @@ class IssuableBaseService < BaseService if issuable.with_transaction_returning_status { issuable.save } # We do not touch as it will affect a update on updated_at field - ActiveRecord::Base.no_touching do + ApplicationRecord.no_touching do Issuable::CommonSystemNotesService.new(project, current_user).execute(issuable, old_associations[:labels]) end diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb index d2bdba1e627..0170d1acb35 100644 --- a/app/services/issues/move_service.rb +++ b/app/services/issues/move_service.rb @@ -20,7 +20,7 @@ module Issues # Using transaction because of a high resources footprint # on rewriting notes (unfolding references) # - ActiveRecord::Base.transaction do + ApplicationRecord.transaction do @new_issue = create_new_issue update_new_issue diff --git a/app/services/projects/propagate_service_template.rb b/app/services/projects/propagate_service_template.rb index 633a263af7b..e814d1d68cd 100644 --- a/app/services/projects/propagate_service_template.rb +++ b/app/services/projects/propagate_service_template.rb @@ -62,7 +62,7 @@ module Projects end def bulk_insert_services(columns, values_array) - ActiveRecord::Base.connection.execute( + ApplicationRecord.connection.execute( <<-SQL.strip_heredoc INSERT INTO services (#{columns.join(', ')}) VALUES #{values_array.map { |tuple| "(#{tuple.join(', ')})" }.join(', ')} @@ -79,8 +79,8 @@ module Projects template_hash.each_with_object({}) do |(key, value), service_hash| value = value.is_a?(Hash) ? value.to_json : value - service_hash[ActiveRecord::Base.connection.quote_column_name(key)] = - ActiveRecord::Base.sanitize(value) + service_hash[ApplicationRecord.connection.quote_column_name(key)] = + ApplicationRecord.sanitize(value) end end end diff --git a/app/services/update_deployment_service.rb b/app/services/update_deployment_service.rb index aa7fcca1e2a..269d490da8a 100644 --- a/app/services/update_deployment_service.rb +++ b/app/services/update_deployment_service.rb @@ -16,7 +16,7 @@ class UpdateDeploymentService deployment.create_ref deployment.invalidate_cache - ActiveRecord::Base.transaction do + ApplicationRecord.transaction do environment.external_url = expanded_environment_url if expanded_environment_url diff --git a/config/initializers/8_metrics.rb b/config/initializers/8_metrics.rb index 468f80939d7..fc2618f162c 100644 --- a/config/initializers/8_metrics.rb +++ b/config/initializers/8_metrics.rb @@ -138,7 +138,7 @@ if Gitlab::Metrics.enabled? && !Rails.env.test? && !(Rails.env.development? && d ) Gitlab::Metrics::Instrumentation - .instrument_class_hierarchy(ActiveRecord::Base) do |klass, method| + .instrument_class_hierarchy(ApplicationRecord) do |klass, method| # Instrumenting the ApplicationSetting class can lead to an infinite # loop. Since the data is cached any way we don't really need to # instrument it. diff --git a/config/initializers/active_record_data_types.rb b/config/initializers/active_record_data_types.rb index 717e30b5b7e..3f8592d9381 100644 --- a/config/initializers/active_record_data_types.rb +++ b/config/initializers/active_record_data_types.rb @@ -81,6 +81,6 @@ elsif Gitlab::Database.mysql? end # Ensure `datetime_with_timezone` columns are correctly written to schema.rb -if (ActiveRecord::Base.connection.active? rescue false) - ActiveRecord::Base.connection.send :reload_type_map +if (ApplicationRecord.connection.active? rescue false) + ApplicationRecord.connection.send :reload_type_map end diff --git a/config/initializers/active_record_lifecycle.rb b/config/initializers/active_record_lifecycle.rb index 7fa37121efc..5b3adf8006f 100644 --- a/config/initializers/active_record_lifecycle.rb +++ b/config/initializers/active_record_lifecycle.rb @@ -2,21 +2,21 @@ # Don't handle sidekiq configuration as it # has its own special active record configuration here -if defined?(ActiveRecord::Base) && !Sidekiq.server? +if defined?(ApplicationRecord) && !Sidekiq.server? Gitlab::Cluster::LifecycleEvents.on_worker_start do ActiveSupport.on_load(:active_record) do - ActiveRecord::Base.establish_connection + ApplicationRecord.establish_connection Rails.logger.debug("ActiveRecord connection established") end end end -if defined?(ActiveRecord::Base) +if defined?(ApplicationRecord) Gitlab::Cluster::LifecycleEvents.on_before_fork do # the following is highly recommended for Rails + "preload_app true" # as there's no need for the master process to hold a connection - ActiveRecord::Base.connection.disconnect! + ApplicationRecord.connection.disconnect! Rails.logger.debug("ActiveRecord connection disconnected") end diff --git a/config/initializers/active_record_migration.rb b/config/initializers/active_record_migration.rb index 04c06be7834..64bb5b3b1bc 100644 --- a/config/initializers/active_record_migration.rb +++ b/config/initializers/active_record_migration.rb @@ -4,7 +4,7 @@ module ActiveRecord class Migration # data_source_exists? is not available in 4.2.10, table_exists deprecated in 5.0 def table_exists?(table_name) - ActiveRecord::Base.connection.data_source_exists?(table_name) + ApplicationRecord.connection.data_source_exists?(table_name) end end end diff --git a/config/initializers/attr_encrypted_no_db_connection.rb b/config/initializers/attr_encrypted_no_db_connection.rb index e007666b852..5ea70a91472 100644 --- a/config/initializers/attr_encrypted_no_db_connection.rb +++ b/config/initializers/attr_encrypted_no_db_connection.rb @@ -4,7 +4,7 @@ module AttrEncrypted module DBConnectionQuerier def attribute_instance_methods_as_symbols # Use with_connection so the connection doesn't stay pinned to the thread. - connected = ::ActiveRecord::Base.connection_pool.with_connection(&:active?) rescue false + connected = ::ApplicationRecord.connection_pool.with_connection(&:active?) rescue false if connected # Call version from AttrEncrypted::Adapters::ActiveRecord diff --git a/config/initializers/mysql_set_length_for_binary_indexes.rb b/config/initializers/mysql_set_length_for_binary_indexes.rb index 0445d8fcae2..16bde581a4d 100644 --- a/config/initializers/mysql_set_length_for_binary_indexes.rb +++ b/config/initializers/mysql_set_length_for_binary_indexes.rb @@ -9,7 +9,7 @@ module MysqlSetLengthForBinaryIndex def add_index(table_name, column_names, options = {}) options[:length] ||= {} Array(column_names).each do |column_name| - column = ActiveRecord::Base.connection.columns(table_name).find { |c| c.name == column_name } + column = ApplicationRecord.connection.columns(table_name).find { |c| c.name == column_name } if column&.type == :binary options[:length][column_name] = 20 diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 565efc858d1..0971fc13fb8 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -35,7 +35,7 @@ Sidekiq.configure_server do |config| config.on :startup do # Clear any connections that might have been obtained before starting # Sidekiq (e.g. in an initializer). - ActiveRecord::Base.clear_all_connections! + ApplicationRecord.clear_all_connections! end if Feature.enabled?(:gitlab_sidekiq_reliable_fetcher) @@ -62,8 +62,8 @@ Sidekiq.configure_server do |config| db_config = Gitlab::Database.config || Rails.application.config.database_configuration[Rails.env] db_config['pool'] = Sidekiq.options[:concurrency] - ActiveRecord::Base.establish_connection(db_config) - Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}") + ApplicationRecord.establish_connection(db_config) + Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{ApplicationRecord.connection.pool.instance_variable_get('@size')}") # Avoid autoload issue such as 'Mail::Parsers::AddressStruct' # https://github.com/mikel/mail/issues/912#issuecomment-214850355 diff --git a/db/importers/common_metrics_importer.rb b/db/importers/common_metrics_importer.rb index 6302394d7a6..eb3106838af 100644 --- a/db/importers/common_metrics_importer.rb +++ b/db/importers/common_metrics_importer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Importers - class PrometheusMetric < ActiveRecord::Base + class PrometheusMetric < ApplicationRecord enum group: { # built-in groups nginx_ingress: -1, diff --git a/db/migrate/20151020173516_ci_limits_to_mysql.rb b/db/migrate/20151020173516_ci_limits_to_mysql.rb index 9bb960082f5..13ed42c48b4 100644 --- a/db/migrate/20151020173516_ci_limits_to_mysql.rb +++ b/db/migrate/20151020173516_ci_limits_to_mysql.rb @@ -1,6 +1,6 @@ class CiLimitsToMysql < ActiveRecord::Migration def change - return unless ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/ + return unless ApplicationRecord.configurations[Rails.env]['adapter'] =~ /^mysql/ # CI change_column :ci_builds, :trace, :text, limit: 1073741823 diff --git a/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb b/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb index d3ea956952e..86920c80607 100644 --- a/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb +++ b/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb @@ -75,6 +75,6 @@ class RemoveDotAtomPathEndingOfProjects < ActiveRecord::Migration end def sanitize(value) - ActiveRecord::Base.connection.quote(value) + ApplicationRecord.connection.quote(value) end end diff --git a/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb b/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb index a80a57254dd..05d003e6424 100644 --- a/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb +++ b/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb @@ -30,7 +30,7 @@ class DropGitoriousFieldFromApplicationSettings < ActiveRecord::Migration private def connection - ActiveRecord::Base.connection + ApplicationRecord.connection end def update_yaml(yaml) diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb index 1eb6a8fa5df..3faec5cd3f0 100644 --- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb +++ b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb @@ -14,7 +14,7 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration end end - class Project < ActiveRecord::Base + class Project < ApplicationRecord def self.find_including_path(id) select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace") .joins('INNER JOIN namespaces ON namespaces.id = projects.namespace_id') diff --git a/db/migrate/20170330141723_disable_invalid_service_templates2.rb b/db/migrate/20170330141723_disable_invalid_service_templates2.rb index 8424e56d8a1..be49fe4edbf 100644 --- a/db/migrate/20170330141723_disable_invalid_service_templates2.rb +++ b/db/migrate/20170330141723_disable_invalid_service_templates2.rb @@ -5,7 +5,7 @@ class DisableInvalidServiceTemplates2 < ActiveRecord::Migration DOWNTIME = false unless defined?(Service) - class Service < ActiveRecord::Base + class Service < ApplicationRecord self.inheritance_column = nil end end diff --git a/db/migrate/20170503140201_reschedule_project_authorizations.rb b/db/migrate/20170503140201_reschedule_project_authorizations.rb index fa45adadbae..252f164f6c9 100644 --- a/db/migrate/20170503140201_reschedule_project_authorizations.rb +++ b/db/migrate/20170503140201_reschedule_project_authorizations.rb @@ -8,7 +8,7 @@ class RescheduleProjectAuthorizations < ActiveRecord::Migration disable_ddl_transaction! - class User < ActiveRecord::Base + class User < ApplicationRecord self.table_name = 'users' end diff --git a/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb b/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb index eed9f00d8b2..498343f7519 100644 --- a/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb +++ b/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb @@ -34,7 +34,7 @@ class MigrateAssigneeToSeparateTable < ActiveRecord::Migration SELECT assignee_id AS user_id, id AS issue_id FROM issues WHERE assignee_id IS NOT NULL EOF else - ActiveRecord::Base.transaction do + ApplicationRecord.transaction do execute('LOCK TABLE issues IN EXCLUSIVE MODE') execute <<-EOF diff --git a/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb b/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb index 12352d98a62..cc13547f4d4 100644 --- a/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb +++ b/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb @@ -178,7 +178,7 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration def connection # Rails memoizes connection objects, but this causes them to be shared # amongst threads; we don't want that. - Thread.current[:foreign_key_connection] || ActiveRecord::Base.connection + Thread.current[:foreign_key_connection] || ApplicationRecord.connection end def queues_for_rows(rows) diff --git a/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb b/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb index c409915ceed..975cfedb0cf 100644 --- a/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb +++ b/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb @@ -5,7 +5,7 @@ class AddForeignKeyToMergeRequests < ActiveRecord::Migration disable_ddl_transaction! - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord self.table_name = 'merge_requests' include ::EachBatch end diff --git a/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb b/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb index 5551fb51a6e..8fe95981ad4 100644 --- a/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb +++ b/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb @@ -9,7 +9,7 @@ class AddBroadcastMessageNotNullConstraints < ActiveRecord::Migration COLUMNS = %i[starts_at ends_at created_at updated_at message_html] - class BroadcastMessage < ActiveRecord::Base + class BroadcastMessage < ApplicationRecord self.table_name = 'broadcast_messages' end diff --git a/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb b/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb index c5fb5762d61..d023086e186 100644 --- a/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb +++ b/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb @@ -4,18 +4,18 @@ class MigrateIssuesToGhostUser < ActiveRecord::Migration disable_ddl_transaction! - class User < ActiveRecord::Base + class User < ApplicationRecord self.table_name = 'users' end - class Issue < ActiveRecord::Base + class Issue < ApplicationRecord self.table_name = 'issues' include ::EachBatch end def reset_column_in_migration_models - ActiveRecord::Base.clear_cache! + ApplicationRecord.clear_cache! ::User.reset_column_information ::Namespace.reset_column_information diff --git a/db/migrate/20170828135939_migrate_user_external_mail_data.rb b/db/migrate/20170828135939_migrate_user_external_mail_data.rb index f7ac87374b6..d5f25b0ec8a 100644 --- a/db/migrate/20170828135939_migrate_user_external_mail_data.rb +++ b/db/migrate/20170828135939_migrate_user_external_mail_data.rb @@ -8,13 +8,13 @@ class MigrateUserExternalMailData < ActiveRecord::Migration disable_ddl_transaction! - class User < ActiveRecord::Base + class User < ApplicationRecord self.table_name = 'users' include EachBatch end - class UserSyncedAttributesMetadata < ActiveRecord::Base + class UserSyncedAttributesMetadata < ApplicationRecord self.table_name = 'user_synced_attributes_metadata' include EachBatch diff --git a/db/migrate/20170830131015_swap_event_migration_tables.rb b/db/migrate/20170830131015_swap_event_migration_tables.rb index a256de4a8af..db2612b9419 100644 --- a/db/migrate/20170830131015_swap_event_migration_tables.rb +++ b/db/migrate/20170830131015_swap_event_migration_tables.rb @@ -7,7 +7,7 @@ class SwapEventMigrationTables < ActiveRecord::Migration # Set this constant to true if this migration requires downtime. DOWNTIME = false - class Event < ActiveRecord::Base + class Event < ApplicationRecord self.table_name = 'events' end diff --git a/db/migrate/20170912113435_clean_stages_statuses_migration.rb b/db/migrate/20170912113435_clean_stages_statuses_migration.rb index fc091d7894e..bd2bd262108 100644 --- a/db/migrate/20170912113435_clean_stages_statuses_migration.rb +++ b/db/migrate/20170912113435_clean_stages_statuses_migration.rb @@ -5,7 +5,7 @@ class CleanStagesStatusesMigration < ActiveRecord::Migration disable_ddl_transaction! - class Stage < ActiveRecord::Base + class Stage < ApplicationRecord include ::EachBatch self.table_name = 'ci_stages' end diff --git a/db/migrate/20171106132212_issues_confidential_not_null.rb b/db/migrate/20171106132212_issues_confidential_not_null.rb index c959d2dd938..9810475837c 100644 --- a/db/migrate/20171106132212_issues_confidential_not_null.rb +++ b/db/migrate/20171106132212_issues_confidential_not_null.rb @@ -7,7 +7,7 @@ class IssuesConfidentialNotNull < ActiveRecord::Migration # Set this constant to true if this migration requires downtime. DOWNTIME = false - class Issue < ActiveRecord::Base + class Issue < ApplicationRecord self.table_name = 'issues' end diff --git a/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb b/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb index bfb3dcae511..7ab84132cef 100644 --- a/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb +++ b/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb @@ -9,7 +9,7 @@ class IssuesMilestoneIdForeignKey < ActiveRecord::Migration disable_ddl_transaction! - class Issue < ActiveRecord::Base + class Issue < ApplicationRecord include EachBatch self.table_name = 'issues' diff --git a/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb b/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb index 3b8844d7d9f..9a4366fbe70 100644 --- a/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb +++ b/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb @@ -9,7 +9,7 @@ class IssuesUpdatedByIdForeignKey < ActiveRecord::Migration disable_ddl_transaction! - class Issue < ActiveRecord::Base + class Issue < ApplicationRecord include EachBatch self.table_name = 'issues' diff --git a/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb b/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb index 6395462384b..ca2ba7eade9 100644 --- a/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb +++ b/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb @@ -9,7 +9,7 @@ class IssuesMovedToIdForeignKey < ActiveRecord::Migration disable_ddl_transaction! - class Issue < ActiveRecord::Base + class Issue < ApplicationRecord include EachBatch self.table_name = 'issues' diff --git a/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb b/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb index 021eaa04a0c..f1f4d4c5e22 100644 --- a/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb +++ b/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb @@ -9,7 +9,7 @@ class MergeRequestsAuthorIdForeignKey < ActiveRecord::Migration disable_ddl_transaction! - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord include EachBatch self.table_name = 'merge_requests' diff --git a/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb b/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb index 1a242f01051..4feb64b942f 100644 --- a/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb +++ b/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb @@ -9,7 +9,7 @@ class MergeRequestsAssigneeIdForeignKey < ActiveRecord::Migration disable_ddl_transaction! - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord include EachBatch self.table_name = 'merge_requests' diff --git a/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb b/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb index eb3872e38da..e73b89ff320 100644 --- a/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb +++ b/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb @@ -9,7 +9,7 @@ class MergeRequestsUpdatedByIdForeignKey < ActiveRecord::Migration disable_ddl_transaction! - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord include EachBatch self.table_name = 'merge_requests' diff --git a/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb b/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb index 925b3e537d7..c23da34b286 100644 --- a/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb +++ b/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb @@ -9,7 +9,7 @@ class MergeRequestsMergeUserIdForeignKey < ActiveRecord::Migration disable_ddl_transaction! - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord include EachBatch self.table_name = 'merge_requests' diff --git a/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb b/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb index 99740f64fe6..9f7edc0e60b 100644 --- a/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb +++ b/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb @@ -9,7 +9,7 @@ class MergeRequestsSourceProjectIdForeignKey < ActiveRecord::Migration disable_ddl_transaction! - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord include EachBatch self.table_name = 'merge_requests' diff --git a/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb b/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb index c005cf7d173..986108ada83 100644 --- a/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb +++ b/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb @@ -9,7 +9,7 @@ class MergeRequestsMilestoneIdForeignKey < ActiveRecord::Migration disable_ddl_transaction! - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord include EachBatch self.table_name = 'merge_requests' diff --git a/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb b/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb index 27b6b4ebddc..7b1daf4c24e 100644 --- a/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb +++ b/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb @@ -5,7 +5,7 @@ class PopulateMergeRequestsLatestMergeRequestDiffIdTakeTwo < ActiveRecord::Migra DOWNTIME = false BATCH_SIZE = 1_000 - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord self.table_name = 'merge_requests' include ::EachBatch diff --git a/db/migrate/20171121135738_clean_up_from_merge_request_diffs_and_commits.rb b/db/migrate/20171121135738_clean_up_from_merge_request_diffs_and_commits.rb index 30cf08b29fc..46db65179c5 100644 --- a/db/migrate/20171121135738_clean_up_from_merge_request_diffs_and_commits.rb +++ b/db/migrate/20171121135738_clean_up_from_merge_request_diffs_and_commits.rb @@ -3,7 +3,7 @@ class CleanUpFromMergeRequestDiffsAndCommits < ActiveRecord::Migration DOWNTIME = false - class MergeRequestDiff < ActiveRecord::Base + class MergeRequestDiff < ApplicationRecord self.table_name = 'merge_request_diffs' include ::EachBatch diff --git a/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb b/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb index 72fbab59f4c..d0a2aa7d9b7 100644 --- a/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb +++ b/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb @@ -9,7 +9,7 @@ class PopulateMissingMergeRequestStatuses < ActiveRecord::Migration disable_ddl_transaction! - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord include EachBatch self.table_name = 'merge_requests' diff --git a/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb b/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb index 680855af945..6544bd064cc 100644 --- a/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb +++ b/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb @@ -10,7 +10,7 @@ class PopulateCanPushFromDeployKeysProjects < ActiveRecord::Migration disable_ddl_transaction! - class DeploysKeyProject < ActiveRecord::Base + class DeploysKeyProject < ApplicationRecord include EachBatch self.table_name = 'deploy_keys_projects' diff --git a/db/migrate/20171216111734_clean_up_for_members.rb b/db/migrate/20171216111734_clean_up_for_members.rb index 22e0997dce6..1a605e6e0b6 100644 --- a/db/migrate/20171216111734_clean_up_for_members.rb +++ b/db/migrate/20171216111734_clean_up_for_members.rb @@ -9,7 +9,7 @@ class CleanUpForMembers < ActiveRecord::Migration disable_ddl_transaction! - class Member < ActiveRecord::Base + class Member < ApplicationRecord include EachBatch self.table_name = 'members' diff --git a/db/migrate/20180105212544_add_commits_count_to_merge_request_diff.rb b/db/migrate/20180105212544_add_commits_count_to_merge_request_diff.rb index f942b4c062e..d3dd742ed54 100644 --- a/db/migrate/20180105212544_add_commits_count_to_merge_request_diff.rb +++ b/db/migrate/20180105212544_add_commits_count_to_merge_request_diff.rb @@ -7,7 +7,7 @@ class AddCommitsCountToMergeRequestDiff < ActiveRecord::Migration BATCH_SIZE = 5000 DELAY_INTERVAL = 5.minutes.to_i - class MergeRequestDiff < ActiveRecord::Base + class MergeRequestDiff < ApplicationRecord self.table_name = 'merge_request_diffs' include ::EachBatch diff --git a/db/migrate/20180201110056_add_foreign_keys_to_todos.rb b/db/migrate/20180201110056_add_foreign_keys_to_todos.rb index 020b0550321..f55b7f91113 100644 --- a/db/migrate/20180201110056_add_foreign_keys_to_todos.rb +++ b/db/migrate/20180201110056_add_foreign_keys_to_todos.rb @@ -1,7 +1,7 @@ class AddForeignKeysToTodos < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - class Todo < ActiveRecord::Base + class Todo < ApplicationRecord self.table_name = 'todos' include EachBatch end diff --git a/db/migrate/20180201145907_migrate_remaining_issues_closed_at.rb b/db/migrate/20180201145907_migrate_remaining_issues_closed_at.rb index 36a85b61968..afb75777a3d 100644 --- a/db/migrate/20180201145907_migrate_remaining_issues_closed_at.rb +++ b/db/migrate/20180201145907_migrate_remaining_issues_closed_at.rb @@ -9,7 +9,7 @@ class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration disable_ddl_transaction! - class Issue < ActiveRecord::Base + class Issue < ApplicationRecord self.table_name = 'issues' include EachBatch end diff --git a/db/migrate/20180206200543_reset_events_primary_key_sequence.rb b/db/migrate/20180206200543_reset_events_primary_key_sequence.rb index eb5c4a6a1e7..e096511b503 100644 --- a/db/migrate/20180206200543_reset_events_primary_key_sequence.rb +++ b/db/migrate/20180206200543_reset_events_primary_key_sequence.rb @@ -7,7 +7,7 @@ class ResetEventsPrimaryKeySequence < ActiveRecord::Migration # Set this constant to true if this migration requires downtime. DOWNTIME = false - class Event < ActiveRecord::Base + class Event < ApplicationRecord self.table_name = 'events' end diff --git a/db/migrate/20180208183958_schedule_populate_untracked_uploads_if_needed.rb b/db/migrate/20180208183958_schedule_populate_untracked_uploads_if_needed.rb index e46e793d9d2..ab0b9835bb6 100644 --- a/db/migrate/20180208183958_schedule_populate_untracked_uploads_if_needed.rb +++ b/db/migrate/20180208183958_schedule_populate_untracked_uploads_if_needed.rb @@ -8,7 +8,7 @@ class SchedulePopulateUntrackedUploadsIfNeeded < ActiveRecord::Migration FOLLOW_UP_MIGRATION = 'PopulateUntrackedUploads'.freeze - class UntrackedFile < ActiveRecord::Base + class UntrackedFile < ApplicationRecord include EachBatch self.table_name = 'untracked_files_for_uploads' diff --git a/db/migrate/20180216120050_pages_domains_verification_grace_period.rb b/db/migrate/20180216120050_pages_domains_verification_grace_period.rb index d7f8634b536..5091ceea021 100644 --- a/db/migrate/20180216120050_pages_domains_verification_grace_period.rb +++ b/db/migrate/20180216120050_pages_domains_verification_grace_period.rb @@ -1,7 +1,7 @@ class PagesDomainsVerificationGracePeriod < ActiveRecord::Migration DOWNTIME = false - class PagesDomain < ActiveRecord::Base + class PagesDomain < ApplicationRecord include EachBatch end diff --git a/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb b/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb index 990759104b0..9676b3a2447 100644 --- a/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb +++ b/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb @@ -7,7 +7,7 @@ class RescheduleCommitsCountForMergeRequestDiff < ActiveRecord::Migration BATCH_SIZE = 5000 DELAY_INTERVAL = 5.minutes.to_i - class MergeRequestDiff < ActiveRecord::Base + class MergeRequestDiff < ApplicationRecord self.table_name = 'merge_request_diffs' include ::EachBatch diff --git a/db/migrate/20180420010616_cleanup_build_stage_migration.rb b/db/migrate/20180420010616_cleanup_build_stage_migration.rb index 5e9fe756efd..f8e82f8d3ac 100644 --- a/db/migrate/20180420010616_cleanup_build_stage_migration.rb +++ b/db/migrate/20180420010616_cleanup_build_stage_migration.rb @@ -6,7 +6,7 @@ class CleanupBuildStageMigration < ActiveRecord::Migration disable_ddl_transaction! - class Build < ActiveRecord::Base + class Build < ApplicationRecord include EachBatch self.table_name = 'ci_builds' diff --git a/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb b/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb index 0e991c23bfa..33493e62370 100644 --- a/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb +++ b/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb @@ -5,7 +5,7 @@ class AssureCommitsCountForMergeRequestDiff < ActiveRecord::Migration disable_ddl_transaction! - class MergeRequestDiff < ActiveRecord::Base + class MergeRequestDiff < ApplicationRecord self.table_name = 'merge_request_diffs' include ::EachBatch diff --git a/db/migrate/20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb b/db/migrate/20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb index 82087d15ccb..ca78bcd288b 100644 --- a/db/migrate/20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb +++ b/db/migrate/20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb @@ -3,7 +3,7 @@ class AddNotNullConstraintToProjectMirrorDataForeignKey < ActiveRecord::Migratio DOWNTIME = false - class ProjectImportState < ActiveRecord::Base + class ProjectImportState < ApplicationRecord include EachBatch self.table_name = 'project_mirror_data' diff --git a/db/migrate/20180608091413_add_group_to_todos.rb b/db/migrate/20180608091413_add_group_to_todos.rb index 20ba4849057..8fa9c14fe31 100644 --- a/db/migrate/20180608091413_add_group_to_todos.rb +++ b/db/migrate/20180608091413_add_group_to_todos.rb @@ -5,7 +5,7 @@ class AddGroupToTodos < ActiveRecord::Migration disable_ddl_transaction! - class Todo < ActiveRecord::Base + class Todo < ApplicationRecord self.table_name = 'todos' include ::EachBatch diff --git a/db/migrate/20180702124358_remove_orphaned_routes.rb b/db/migrate/20180702124358_remove_orphaned_routes.rb index 4068e479b6c..54ac3062a86 100644 --- a/db/migrate/20180702124358_remove_orphaned_routes.rb +++ b/db/migrate/20180702124358_remove_orphaned_routes.rb @@ -8,7 +8,7 @@ class RemoveOrphanedRoutes < ActiveRecord::Migration disable_ddl_transaction! - class Route < ActiveRecord::Base + class Route < ApplicationRecord self.table_name = 'routes' include EachBatch diff --git a/db/migrate/20180702134423_generate_missing_routes.rb b/db/migrate/20180702134423_generate_missing_routes.rb index 994725f9bd1..31a1862eefe 100644 --- a/db/migrate/20180702134423_generate_missing_routes.rb +++ b/db/migrate/20180702134423_generate_missing_routes.rb @@ -14,11 +14,11 @@ class GenerateMissingRoutes < ActiveRecord::Migration disable_ddl_transaction! - class User < ActiveRecord::Base + class User < ApplicationRecord self.table_name = 'users' end - class Route < ActiveRecord::Base + class Route < ApplicationRecord self.table_name = 'routes' end @@ -63,7 +63,7 @@ class GenerateMissingRoutes < ActiveRecord::Migration end end - class Project < ActiveRecord::Base + class Project < ApplicationRecord self.table_name = 'projects' include EachBatch @@ -96,7 +96,7 @@ class GenerateMissingRoutes < ActiveRecord::Migration end end - class Namespace < ActiveRecord::Base + class Namespace < ApplicationRecord self.table_name = 'namespaces' include EachBatch diff --git a/db/migrate/20180710162338_add_foreign_key_from_notification_settings_to_users.rb b/db/migrate/20180710162338_add_foreign_key_from_notification_settings_to_users.rb index 91656f194e5..61a3b7737dc 100644 --- a/db/migrate/20180710162338_add_foreign_key_from_notification_settings_to_users.rb +++ b/db/migrate/20180710162338_add_foreign_key_from_notification_settings_to_users.rb @@ -1,13 +1,13 @@ class AddForeignKeyFromNotificationSettingsToUsers < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - class NotificationSetting < ActiveRecord::Base + class NotificationSetting < ApplicationRecord self.table_name = 'notification_settings' include EachBatch end - class User < ActiveRecord::Base + class User < ApplicationRecord self.table_name = 'users' end diff --git a/db/migrate/20180711103851_drop_duplicate_protected_tags.rb b/db/migrate/20180711103851_drop_duplicate_protected_tags.rb index 8fa2137551e..6975e6d69e5 100644 --- a/db/migrate/20180711103851_drop_duplicate_protected_tags.rb +++ b/db/migrate/20180711103851_drop_duplicate_protected_tags.rb @@ -8,13 +8,13 @@ class DropDuplicateProtectedTags < ActiveRecord::Migration BATCH_SIZE = 1000 - class Project < ActiveRecord::Base + class Project < ApplicationRecord self.table_name = 'projects' include ::EachBatch end - class ProtectedTag < ActiveRecord::Base + class ProtectedTag < ApplicationRecord self.table_name = 'protected_tags' end diff --git a/db/migrate/20180717125853_remove_restricted_todos.rb b/db/migrate/20180717125853_remove_restricted_todos.rb index fdf43921a73..1d9de89f08c 100644 --- a/db/migrate/20180717125853_remove_restricted_todos.rb +++ b/db/migrate/20180717125853_remove_restricted_todos.rb @@ -10,7 +10,7 @@ class RemoveRestrictedTodos < ActiveRecord::Migration BATCH_SIZE = 1000 DELAY_INTERVAL = 5.minutes.to_i - class Project < ActiveRecord::Base + class Project < ApplicationRecord include EachBatch self.table_name = 'projects' diff --git a/db/migrate/20180925200829_create_user_preferences.rb b/db/migrate/20180925200829_create_user_preferences.rb index 755cabdabde..a6f55caf65d 100644 --- a/db/migrate/20180925200829_create_user_preferences.rb +++ b/db/migrate/20180925200829_create_user_preferences.rb @@ -3,7 +3,7 @@ class CreateUserPreferences < ActiveRecord::Migration DOWNTIME = false - class UserPreference < ActiveRecord::Base + class UserPreference < ApplicationRecord self.table_name = 'user_preferences' NOTES_FILTERS = { all_notes: 0, comments: 1 }.freeze diff --git a/db/migrate/20181002172433_remove_restricted_todos_with_cte.rb b/db/migrate/20181002172433_remove_restricted_todos_with_cte.rb index 0a8f4a12266..7885e72e9ed 100644 --- a/db/migrate/20181002172433_remove_restricted_todos_with_cte.rb +++ b/db/migrate/20181002172433_remove_restricted_todos_with_cte.rb @@ -11,7 +11,7 @@ class RemoveRestrictedTodosWithCte < ActiveRecord::Migration BATCH_SIZE = 1000 DELAY_INTERVAL = 5.minutes.to_i - class Project < ActiveRecord::Base + class Project < ApplicationRecord include EachBatch self.table_name = 'projects' diff --git a/db/migrate/20181026143227_migrate_snippets_access_level_default_value.rb b/db/migrate/20181026143227_migrate_snippets_access_level_default_value.rb index ede0ee27b8a..6962c1ecd2e 100644 --- a/db/migrate/20181026143227_migrate_snippets_access_level_default_value.rb +++ b/db/migrate/20181026143227_migrate_snippets_access_level_default_value.rb @@ -11,7 +11,7 @@ class MigrateSnippetsAccessLevelDefaultValue < ActiveRecord::Migration disable_ddl_transaction! - class ProjectFeature < ActiveRecord::Base + class ProjectFeature < ApplicationRecord include EachBatch self.table_name = 'project_features' diff --git a/db/migrate/limits_to_mysql.rb b/db/migrate/limits_to_mysql.rb index 7507a4bb431..39788ac596e 100644 --- a/db/migrate/limits_to_mysql.rb +++ b/db/migrate/limits_to_mysql.rb @@ -1,6 +1,6 @@ class LimitsToMysql < ActiveRecord::Migration def up - return unless ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/ + return unless ApplicationRecord.configurations[Rails.env]['adapter'] =~ /^mysql/ # These columns were removed in 10.3, but this is called from two places: # 1. A migration run after they were added, but before they were removed. diff --git a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb index f058e85c1ec..2887060ffa9 100644 --- a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb +++ b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb @@ -39,7 +39,7 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration .set(projects[:visibility_level] => visibility_level) .where(projects[:id].in(project_ids)) - ActiveRecord::Base.connection.exec_update(updater.to_sql, self.class.name, []) + ApplicationRecord.connection.exec_update(updater.to_sql, self.class.name, []) end end end diff --git a/db/post_migrate/20161221153951_rename_reserved_project_names.rb b/db/post_migrate/20161221153951_rename_reserved_project_names.rb index 678876e886c..600566435f1 100644 --- a/db/post_migrate/20161221153951_rename_reserved_project_names.rb +++ b/db/post_migrate/20161221153951_rename_reserved_project_names.rb @@ -84,9 +84,9 @@ class RenameReservedProjectNames < ActiveRecord::Migration end def route_exists?(full_path) - quoted_path = ActiveRecord::Base.connection.quote_string(full_path) + quoted_path = ApplicationRecord.connection.quote_string(full_path) - ActiveRecord::Base.connection + ApplicationRecord.connection .select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present? end diff --git a/db/post_migrate/20170106142508_fill_authorized_projects.rb b/db/post_migrate/20170106142508_fill_authorized_projects.rb index 0ca20587981..6aeb2b7a029 100644 --- a/db/post_migrate/20170106142508_fill_authorized_projects.rb +++ b/db/post_migrate/20170106142508_fill_authorized_projects.rb @@ -4,7 +4,7 @@ class FillAuthorizedProjects < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - class User < ActiveRecord::Base + class User < ApplicationRecord self.table_name = 'users' end diff --git a/db/post_migrate/20170211073944_disable_invalid_service_templates.rb b/db/post_migrate/20170211073944_disable_invalid_service_templates.rb index 603efc43782..5b19ae36cc3 100644 --- a/db/post_migrate/20170211073944_disable_invalid_service_templates.rb +++ b/db/post_migrate/20170211073944_disable_invalid_service_templates.rb @@ -1,7 +1,7 @@ class DisableInvalidServiceTemplates < ActiveRecord::Migration DOWNTIME = false - class Service < ActiveRecord::Base + class Service < ApplicationRecord self.inheritance_column = nil end diff --git a/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb b/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb index 04bf89c9687..5716d89282c 100644 --- a/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb +++ b/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb @@ -44,7 +44,7 @@ class MigrateBuildEventsToPipelineEvents < ActiveRecord::Migration def connection # Rails memoizes connection objects, but this causes them to be shared # amongst threads; we don't want that. - Thread.current[:foreign_key_connection] || ActiveRecord::Base.connection + Thread.current[:foreign_key_connection] || ApplicationRecord.connection end private diff --git a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb index 26a67b0f814..489be407f06 100644 --- a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb +++ b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb @@ -26,9 +26,9 @@ class RenameMoreReservedProjectNames < ActiveRecord::Migration end def route_exists?(full_path) - quoted_path = ActiveRecord::Base.connection.quote_string(full_path) + quoted_path = ApplicationRecord.connection.quote_string(full_path) - ActiveRecord::Base.connection + ApplicationRecord.connection .select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present? end diff --git a/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb b/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb index 006d17b4d62..7f756f75d88 100644 --- a/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb +++ b/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb @@ -25,7 +25,7 @@ class RemoveAssigneeIdFromIssue < ActiveRecord::Migration # comments: disable_ddl_transaction! - class Issue < ActiveRecord::Base + class Issue < ApplicationRecord self.table_name = 'issues' include ::EachBatch diff --git a/db/post_migrate/20170523083112_migrate_old_artifacts.rb b/db/post_migrate/20170523083112_migrate_old_artifacts.rb index 3a77b9751d3..cf02dd68270 100644 --- a/db/post_migrate/20170523083112_migrate_old_artifacts.rb +++ b/db/post_migrate/20170523083112_migrate_old_artifacts.rb @@ -34,7 +34,7 @@ class MigrateOldArtifacts < ActiveRecord::Migration .first end - class Build < ActiveRecord::Base + class Build < ApplicationRecord self.table_name = 'ci_builds' scope :with_artifacts, -> { where.not(artifacts_file: [nil, '']) } diff --git a/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb b/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb index 9abda6a1d73..332f29487fa 100644 --- a/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb +++ b/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb @@ -5,7 +5,7 @@ class ConvertCustomNotificationSettingsToColumns < ActiveRecord::Migration disable_ddl_transaction! - class NotificationSetting < ActiveRecord::Base + class NotificationSetting < ApplicationRecord self.table_name = 'notification_settings' store :events, coder: JSON diff --git a/db/post_migrate/20170627101016_schedule_event_migrations.rb b/db/post_migrate/20170627101016_schedule_event_migrations.rb index 1e020d05f78..040be50774d 100644 --- a/db/post_migrate/20170627101016_schedule_event_migrations.rb +++ b/db/post_migrate/20170627101016_schedule_event_migrations.rb @@ -9,7 +9,7 @@ class ScheduleEventMigrations < ActiveRecord::Migration disable_ddl_transaction! - class Event < ActiveRecord::Base + class Event < ApplicationRecord include EachBatch self.table_name = 'events' diff --git a/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb b/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb index f31015d77a3..d7cfd613846 100644 --- a/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb +++ b/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb @@ -8,7 +8,7 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration disable_ddl_transaction! - class Build < ActiveRecord::Base + class Build < ApplicationRecord self.table_name = 'ci_builds' include ::EachBatch end diff --git a/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb b/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb index 17a9dc293f1..c3d1eb45aa6 100644 --- a/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb +++ b/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb @@ -7,7 +7,7 @@ class ScheduleMergeRequestDiffMigrations < ActiveRecord::Migration disable_ddl_transaction! - class MergeRequestDiff < ActiveRecord::Base + class MergeRequestDiff < ApplicationRecord self.table_name = 'merge_request_diffs' include ::EachBatch diff --git a/db/post_migrate/20170711145558_migrate_stages_statuses.rb b/db/post_migrate/20170711145558_migrate_stages_statuses.rb index 265f7317b9b..fb93a6845c2 100644 --- a/db/post_migrate/20170711145558_migrate_stages_statuses.rb +++ b/db/post_migrate/20170711145558_migrate_stages_statuses.rb @@ -9,7 +9,7 @@ class MigrateStagesStatuses < ActiveRecord::Migration RANGE_SIZE = 100 MIGRATION = 'MigrateStageStatus'.freeze - class Stage < ActiveRecord::Base + class Stage < ApplicationRecord self.table_name = 'ci_stages' include ::EachBatch end diff --git a/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb b/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb index acc0fc7a0ac..ccddf0e3530 100644 --- a/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb +++ b/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb @@ -8,13 +8,13 @@ class MergeIssuableReopenedIntoOpenedState < ActiveRecord::Migration disable_ddl_transaction! - class Issue < ActiveRecord::Base + class Issue < ApplicationRecord self.table_name = 'issues' include EachBatch end - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord self.table_name = 'merge_requests' include EachBatch diff --git a/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb b/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb index 9af76c94bf3..f74e948826a 100644 --- a/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb +++ b/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb @@ -2,7 +2,7 @@ class CalculateConvDevIndexPercentages < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = false - class ConversationalDevelopmentIndexMetric < ActiveRecord::Base + class ConversationalDevelopmentIndexMetric < ApplicationRecord self.table_name = 'conversational_development_index_metrics' METRICS = %w[boards ci_pipelines deployments environments issues merge_requests milestones notes diff --git a/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb b/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb index 6132b553177..57d2f972524 100644 --- a/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb +++ b/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb @@ -5,7 +5,7 @@ class RemoveDuplicateMrEvents < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = false - class Event < ActiveRecord::Base + class Event < ApplicationRecord self.table_name = 'events' end diff --git a/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb b/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb index 3f085c17133..b78e1540c74 100644 --- a/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb +++ b/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb @@ -8,13 +8,13 @@ class CleanupNonexistingNamespacePendingDeleteProjects < ActiveRecord::Migration disable_ddl_transaction! - class Project < ActiveRecord::Base + class Project < ApplicationRecord self.table_name = 'projects' include ::EachBatch end - class Namespace < ActiveRecord::Base + class Namespace < ApplicationRecord self.table_name = 'namespaces' end diff --git a/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb b/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb index fd1437b07f5..b0f148f0852 100644 --- a/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb +++ b/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb @@ -8,13 +8,13 @@ class PostDeployMigrateUserExternalMailData < ActiveRecord::Migration disable_ddl_transaction! - class User < ActiveRecord::Base + class User < ApplicationRecord self.table_name = 'users' include EachBatch end - class UserSyncedAttributesMetadata < ActiveRecord::Base + class UserSyncedAttributesMetadata < ApplicationRecord self.table_name = 'user_synced_attributes_metadata' include EachBatch diff --git a/db/post_migrate/20170830150306_drop_events_for_migration_table.rb b/db/post_migrate/20170830150306_drop_events_for_migration_table.rb index 69a612ead40..a5f7e3df389 100644 --- a/db/post_migrate/20170830150306_drop_events_for_migration_table.rb +++ b/db/post_migrate/20170830150306_drop_events_for_migration_table.rb @@ -8,7 +8,7 @@ class DropEventsForMigrationTable < ActiveRecord::Migration disable_ddl_transaction! - class Event < ActiveRecord::Base + class Event < ApplicationRecord include EachBatch end diff --git a/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb b/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb index 2230bb0e53c..a5b44b050e4 100644 --- a/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb +++ b/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb @@ -10,7 +10,7 @@ class NormalizeLdapExternUids < ActiveRecord::Migration disable_ddl_transaction! - class Identity < ActiveRecord::Base + class Identity < ApplicationRecord include EachBatch self.table_name = 'identities' diff --git a/db/post_migrate/20170926150348_schedule_merge_request_diff_migrations_take_two.rb b/db/post_migrate/20170926150348_schedule_merge_request_diff_migrations_take_two.rb index 5732cb85ea5..ef1215b9687 100644 --- a/db/post_migrate/20170926150348_schedule_merge_request_diff_migrations_take_two.rb +++ b/db/post_migrate/20170926150348_schedule_merge_request_diff_migrations_take_two.rb @@ -8,7 +8,7 @@ class ScheduleMergeRequestDiffMigrationsTakeTwo < ActiveRecord::Migration disable_ddl_transaction! - class MergeRequestDiff < ActiveRecord::Base + class MergeRequestDiff < ApplicationRecord self.table_name = 'merge_request_diffs' include ::EachBatch diff --git a/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb b/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb index 467c584c2e0..1d0f35ee5f6 100644 --- a/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb +++ b/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb @@ -7,7 +7,7 @@ class ScheduleCreateGpgKeySubkeysFromGpgKeys < ActiveRecord::Migration DOWNTIME = false MIGRATION = 'CreateGpgKeySubkeysFromGpgKeys' - class GpgKey < ActiveRecord::Base + class GpgKey < ApplicationRecord self.table_name = 'gpg_keys' include EachBatch diff --git a/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb b/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb index 28cd0f70cc2..61ce36f42d6 100644 --- a/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb +++ b/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb @@ -1,7 +1,7 @@ class MigrateGcpClustersToNewClustersArchitectures < ActiveRecord::Migration DOWNTIME = false - class GcpCluster < ActiveRecord::Base + class GcpCluster < ApplicationRecord self.table_name = 'gcp_clusters' belongs_to :project, class_name: 'Project' @@ -9,7 +9,7 @@ class MigrateGcpClustersToNewClustersArchitectures < ActiveRecord::Migration include EachBatch end - class Cluster < ActiveRecord::Base + class Cluster < ApplicationRecord self.table_name = 'clusters' has_many :cluster_projects, class_name: 'ClustersProject' @@ -30,25 +30,25 @@ class MigrateGcpClustersToNewClustersArchitectures < ActiveRecord::Migration } end - class Project < ActiveRecord::Base + class Project < ApplicationRecord self.table_name = 'projects' has_one :cluster_project, class_name: 'ClustersProject' has_one :cluster, through: :cluster_project, class_name: 'Cluster' end - class ClustersProject < ActiveRecord::Base + class ClustersProject < ApplicationRecord self.table_name = 'cluster_projects' belongs_to :cluster, class_name: 'Cluster' belongs_to :project, class_name: 'Project' end - class ProvidersGcp < ActiveRecord::Base + class ProvidersGcp < ApplicationRecord self.table_name = 'cluster_providers_gcp' end - class PlatformsKubernetes < ActiveRecord::Base + class PlatformsKubernetes < ApplicationRecord self.table_name = 'cluster_platforms_kubernetes' end diff --git a/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb b/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb index 7a63382cc6d..ab711d9c42e 100644 --- a/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb +++ b/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb @@ -7,7 +7,7 @@ class ScheduleMergeRequestLatestMergeRequestDiffIdMigrations < ActiveRecord::Mig disable_ddl_transaction! - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord self.table_name = 'merge_requests' include ::EachBatch diff --git a/db/post_migrate/20171114104051_remove_empty_fork_networks.rb b/db/post_migrate/20171114104051_remove_empty_fork_networks.rb index 2fe99a1b9c1..91e88e452dd 100644 --- a/db/post_migrate/20171114104051_remove_empty_fork_networks.rb +++ b/db/post_migrate/20171114104051_remove_empty_fork_networks.rb @@ -4,13 +4,13 @@ class RemoveEmptyForkNetworks < ActiveRecord::Migration DOWNTIME = false BATCH_SIZE = 10_000 - class MigrationForkNetwork < ActiveRecord::Base + class MigrationForkNetwork < ApplicationRecord include EachBatch self.table_name = 'fork_networks' end - class MigrationForkNetworkMembers < ActiveRecord::Base + class MigrationForkNetworkMembers < ApplicationRecord self.table_name = 'fork_network_members' end diff --git a/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb b/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb index 8e1c9e6d6bb..3920a882f1a 100644 --- a/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb +++ b/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb @@ -6,7 +6,7 @@ class UpdateCircuitbreakerDefaults < ActiveRecord::Migration DOWNTIME = false - class ApplicationSetting < ActiveRecord::Base; end + class ApplicationSetting < ApplicationRecord; end def up change_column_default :application_settings, diff --git a/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb b/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb index a957f107405..17391132139 100644 --- a/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb +++ b/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb @@ -6,7 +6,7 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati disable_ddl_transaction! - class Project < ActiveRecord::Base + class Project < ApplicationRecord self.table_name = 'projects' has_many :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject' @@ -15,7 +15,7 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati has_one :kubernetes_service, -> { where(category: 'deployment', type: 'KubernetesService') }, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Service', inverse_of: :project, foreign_key: :project_id end - class Cluster < ActiveRecord::Base + class Cluster < ApplicationRecord self.table_name = 'clusters' has_many :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject' @@ -34,14 +34,14 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati } end - class ClustersProject < ActiveRecord::Base + class ClustersProject < ApplicationRecord self.table_name = 'cluster_projects' belongs_to :cluster, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Cluster' belongs_to :project, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Project' end - class PlatformsKubernetes < ActiveRecord::Base + class PlatformsKubernetes < ApplicationRecord self.table_name = 'cluster_platforms_kubernetes' belongs_to :cluster, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Cluster' @@ -52,7 +52,7 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati algorithm: 'aes-256-cbc' end - class Service < ActiveRecord::Base + class Service < ApplicationRecord include EachBatch self.table_name = 'services' @@ -116,7 +116,7 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati end def up - ActiveRecord::Base.transaction do + ApplicationRecord.transaction do MigrateKubernetesServiceToNewClustersArchitectures::Service .unmanaged_kubernetes_service.find_each(batch_size: 1) do |kubernetes_service| MigrateKubernetesServiceToNewClustersArchitectures::Cluster.create( diff --git a/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb b/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb index 980f76e7d57..f4084ed661f 100644 --- a/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb +++ b/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb @@ -7,7 +7,7 @@ class SchedulePopulateMergeRequestMetricsWithEventsData < ActiveRecord::Migratio disable_ddl_transaction! - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord self.table_name = 'merge_requests' include ::EachBatch diff --git a/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb b/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb index 30ff5173192..bdeb8e6d97a 100644 --- a/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb +++ b/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb @@ -9,7 +9,7 @@ class RescheduleForkNetworkCreationCaller < ActiveRecord::Migration disable_ddl_transaction! - class ForkedProjectLink < ActiveRecord::Base + class ForkedProjectLink < ApplicationRecord include EachBatch self.table_name = 'forked_project_links' diff --git a/db/post_migrate/20171207150343_remove_soft_removed_objects.rb b/db/post_migrate/20171207150343_remove_soft_removed_objects.rb index 3109b6dbf8e..c5781d72684 100644 --- a/db/post_migrate/20171207150343_remove_soft_removed_objects.rb +++ b/db/post_migrate/20171207150343_remove_soft_removed_objects.rb @@ -17,27 +17,27 @@ class RemoveSoftRemovedObjects < ActiveRecord::Migration end end - class User < ActiveRecord::Base + class User < ApplicationRecord self.table_name = 'users' include EachBatch end - class Issue < ActiveRecord::Base + class Issue < ApplicationRecord self.table_name = 'issues' include EachBatch include SoftRemoved end - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord self.table_name = 'merge_requests' include EachBatch include SoftRemoved end - class Namespace < ActiveRecord::Base + class Namespace < ApplicationRecord self.table_name = 'namespaces' include EachBatch @@ -47,28 +47,28 @@ class RemoveSoftRemovedObjects < ActiveRecord::Migration scope :soft_removed_group, -> { soft_removed.where(type: 'Group') } end - class Route < ActiveRecord::Base + class Route < ApplicationRecord self.table_name = 'routes' include EachBatch include SoftRemoved end - class Project < ActiveRecord::Base + class Project < ApplicationRecord self.table_name = 'projects' include EachBatch include SoftRemoved end - class CiPipelineSchedule < ActiveRecord::Base + class CiPipelineSchedule < ApplicationRecord self.table_name = 'ci_pipeline_schedules' include EachBatch include SoftRemoved end - class CiTrigger < ActiveRecord::Base + class CiTrigger < ApplicationRecord self.table_name = 'ci_triggers' include EachBatch diff --git a/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb b/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb index 3a5850df3db..bf3aded4070 100644 --- a/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb +++ b/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb @@ -9,7 +9,7 @@ class PostPopulateCanPushFromDeployKeysProjects < ActiveRecord::Migration disable_ddl_transaction! - class DeploysKeyProject < ActiveRecord::Base + class DeploysKeyProject < ApplicationRecord include EachBatch self.table_name = 'deploy_keys_projects' diff --git a/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb b/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb index 286721a0894..33eed651885 100644 --- a/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb +++ b/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb @@ -10,7 +10,7 @@ class NormalizeExternUidFromIdentities < ActiveRecord::Migration disable_ddl_transaction! - class Identity < ActiveRecord::Base + class Identity < ApplicationRecord include EachBatch self.table_name = 'identities' diff --git a/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb b/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb index eeecc7b1de0..85c405f7b48 100644 --- a/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb +++ b/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb @@ -8,7 +8,7 @@ class ScheduleIssuesClosedAtTypeChange < ActiveRecord::Migration disable_ddl_transaction! - class Issue < ActiveRecord::Base + class Issue < ApplicationRecord self.table_name = 'issues' include EachBatch diff --git a/db/post_migrate/20180204200836_change_author_id_to_not_null_in_todos.rb b/db/post_migrate/20180204200836_change_author_id_to_not_null_in_todos.rb index 92c32feebf7..e1ddda663d7 100644 --- a/db/post_migrate/20180204200836_change_author_id_to_not_null_in_todos.rb +++ b/db/post_migrate/20180204200836_change_author_id_to_not_null_in_todos.rb @@ -1,7 +1,7 @@ class ChangeAuthorIdToNotNullInTodos < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - class Todo < ActiveRecord::Base + class Todo < ApplicationRecord self.table_name = 'todos' include EachBatch end diff --git a/db/post_migrate/20180216121020_fill_pages_domain_verification_code.rb b/db/post_migrate/20180216121020_fill_pages_domain_verification_code.rb index d423673d2a5..9614bca2ba6 100644 --- a/db/post_migrate/20180216121020_fill_pages_domain_verification_code.rb +++ b/db/post_migrate/20180216121020_fill_pages_domain_verification_code.rb @@ -1,7 +1,7 @@ class FillPagesDomainVerificationCode < ActiveRecord::Migration DOWNTIME = false - class PagesDomain < ActiveRecord::Base + class PagesDomain < ApplicationRecord include EachBatch end diff --git a/db/post_migrate/20180216121030_enqueue_verify_pages_domain_workers.rb b/db/post_migrate/20180216121030_enqueue_verify_pages_domain_workers.rb index bf9bf4e660f..d772c3e6a5f 100644 --- a/db/post_migrate/20180216121030_enqueue_verify_pages_domain_workers.rb +++ b/db/post_migrate/20180216121030_enqueue_verify_pages_domain_workers.rb @@ -1,5 +1,5 @@ class EnqueueVerifyPagesDomainWorkers < ActiveRecord::Migration - class PagesDomain < ActiveRecord::Base + class PagesDomain < ApplicationRecord include EachBatch end diff --git a/db/post_migrate/20180220150310_remove_empty_extern_uid_auth0_identities.rb b/db/post_migrate/20180220150310_remove_empty_extern_uid_auth0_identities.rb index 2d5a8617169..fe0f32c0c1c 100644 --- a/db/post_migrate/20180220150310_remove_empty_extern_uid_auth0_identities.rb +++ b/db/post_migrate/20180220150310_remove_empty_extern_uid_auth0_identities.rb @@ -5,7 +5,7 @@ class RemoveEmptyExternUidAuth0Identities < ActiveRecord::Migration disable_ddl_transaction! - class Identity < ActiveRecord::Base + class Identity < ApplicationRecord self.table_name = 'identities' include EachBatch end diff --git a/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb b/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb index 8c8dbb1a043..beee6dc99fa 100644 --- a/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb +++ b/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb @@ -127,7 +127,7 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration # Protect table against concurrent data changes while still allowing reads def with_table_lock(*tables) - ActiveRecord::Base.connection.transaction do + ApplicationRecord.connection.transaction do execute "LOCK TABLE #{tables.join(", ")} IN SHARE MODE" yield end diff --git a/db/post_migrate/20180301084653_change_project_namespace_id_not_null.rb b/db/post_migrate/20180301084653_change_project_namespace_id_not_null.rb index 0342372cbed..584af94d8c7 100644 --- a/db/post_migrate/20180301084653_change_project_namespace_id_not_null.rb +++ b/db/post_migrate/20180301084653_change_project_namespace_id_not_null.rb @@ -4,7 +4,7 @@ class ChangeProjectNamespaceIdNotNull < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - class Project < ActiveRecord::Base + class Project < ApplicationRecord self.table_name = 'projects' include EachBatch end diff --git a/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb b/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb index c32123454f9..cc718d2318c 100644 --- a/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb +++ b/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb @@ -11,7 +11,7 @@ class RescheduleBuildsStagesMigration < ActiveRecord::Migration disable_ddl_transaction! - class Build < ActiveRecord::Base + class Build < ApplicationRecord include EachBatch self.table_name = 'ci_builds' end diff --git a/db/post_migrate/20180420080616_schedule_stages_index_migration.rb b/db/post_migrate/20180420080616_schedule_stages_index_migration.rb index eb82f098639..b449370234d 100644 --- a/db/post_migrate/20180420080616_schedule_stages_index_migration.rb +++ b/db/post_migrate/20180420080616_schedule_stages_index_migration.rb @@ -7,7 +7,7 @@ class ScheduleStagesIndexMigration < ActiveRecord::Migration disable_ddl_transaction! - class Stage < ActiveRecord::Base + class Stage < ApplicationRecord include EachBatch self.table_name = 'ci_stages' end diff --git a/db/post_migrate/20180424151928_fill_file_store.rb b/db/post_migrate/20180424151928_fill_file_store.rb index 03d54dab250..76e920efaff 100644 --- a/db/post_migrate/20180424151928_fill_file_store.rb +++ b/db/post_migrate/20180424151928_fill_file_store.rb @@ -5,7 +5,7 @@ class FillFileStore < ActiveRecord::Migration disable_ddl_transaction! - class JobArtifact < ActiveRecord::Base + class JobArtifact < ApplicationRecord include EachBatch self.table_name = 'ci_job_artifacts' BATCH_SIZE = 10_000 @@ -15,7 +15,7 @@ class FillFileStore < ActiveRecord::Migration end end - class LfsObject < ActiveRecord::Base + class LfsObject < ApplicationRecord include EachBatch self.table_name = 'lfs_objects' BATCH_SIZE = 10_000 @@ -25,7 +25,7 @@ class FillFileStore < ActiveRecord::Migration end end - class Upload < ActiveRecord::Base + class Upload < ApplicationRecord include EachBatch self.table_name = 'uploads' self.inheritance_column = :_type_disabled # Disable STI diff --git a/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb b/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb index 08d7d64a2c5..c39ebd5cdfe 100644 --- a/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb +++ b/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb @@ -11,13 +11,13 @@ class MigrateImportAttributesDataFromProjectsToProjectMirrorData < ActiveRecord: disable_ddl_transaction! - class Project < ActiveRecord::Base + class Project < ApplicationRecord include EachBatch self.table_name = 'projects' end - class ProjectImportState < ActiveRecord::Base + class ProjectImportState < ApplicationRecord include EachBatch self.table_name = 'project_mirror_data' diff --git a/db/post_migrate/20180511174224_add_unique_constraint_to_project_features_project_id.rb b/db/post_migrate/20180511174224_add_unique_constraint_to_project_features_project_id.rb index 88a9f5f8256..6f9060b03da 100644 --- a/db/post_migrate/20180511174224_add_unique_constraint_to_project_features_project_id.rb +++ b/db/post_migrate/20180511174224_add_unique_constraint_to_project_features_project_id.rb @@ -5,7 +5,7 @@ class AddUniqueConstraintToProjectFeaturesProjectId < ActiveRecord::Migration disable_ddl_transaction! - class ProjectFeature < ActiveRecord::Base + class ProjectFeature < ApplicationRecord self.table_name = 'project_features' include EachBatch diff --git a/db/post_migrate/20180512061621_add_not_null_constraint_to_project_features_project_id.rb b/db/post_migrate/20180512061621_add_not_null_constraint_to_project_features_project_id.rb index 5a6d6ff4a10..d0574e32a10 100644 --- a/db/post_migrate/20180512061621_add_not_null_constraint_to_project_features_project_id.rb +++ b/db/post_migrate/20180512061621_add_not_null_constraint_to_project_features_project_id.rb @@ -3,7 +3,7 @@ class AddNotNullConstraintToProjectFeaturesProjectId < ActiveRecord::Migration DOWNTIME = false - class ProjectFeature < ActiveRecord::Base + class ProjectFeature < ApplicationRecord include EachBatch self.table_name = 'project_features' diff --git a/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb b/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb index 0282688fa40..2de965dc795 100644 --- a/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb +++ b/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb @@ -8,7 +8,7 @@ class MigrateRemainingMrMetricsPopulatingBackgroundMigration < ActiveRecord::Mig disable_ddl_transaction! - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord self.table_name = 'merge_requests' include ::EachBatch diff --git a/db/post_migrate/20180529152628_schedule_to_archive_legacy_traces.rb b/db/post_migrate/20180529152628_schedule_to_archive_legacy_traces.rb index 965cd3a8714..c8a9e56d5f9 100644 --- a/db/post_migrate/20180529152628_schedule_to_archive_legacy_traces.rb +++ b/db/post_migrate/20180529152628_schedule_to_archive_legacy_traces.rb @@ -7,7 +7,7 @@ class ScheduleToArchiveLegacyTraces < ActiveRecord::Migration disable_ddl_transaction! - class Build < ActiveRecord::Base + class Build < ApplicationRecord include EachBatch self.table_name = 'ci_builds' self.inheritance_column = :_type_disabled # Disable STI diff --git a/db/post_migrate/20180604123514_cleanup_stages_position_migration.rb b/db/post_migrate/20180604123514_cleanup_stages_position_migration.rb index 5418f442e79..cee9e454f25 100644 --- a/db/post_migrate/20180604123514_cleanup_stages_position_migration.rb +++ b/db/post_migrate/20180604123514_cleanup_stages_position_migration.rb @@ -6,7 +6,7 @@ class CleanupStagesPositionMigration < ActiveRecord::Migration disable_ddl_transaction! - class Stages < ActiveRecord::Base + class Stages < ApplicationRecord include EachBatch self.table_name = 'ci_stages' end diff --git a/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb b/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb index 59aa41adede..4d974db8146 100644 --- a/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb +++ b/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb @@ -8,11 +8,11 @@ class EnqueueFixCrossProjectLabelLinks < ActiveRecord::Migration disable_ddl_transaction! - class Label < ActiveRecord::Base + class Label < ApplicationRecord self.table_name = 'labels' end - class Namespace < ActiveRecord::Base + class Namespace < ApplicationRecord self.table_name = 'namespaces' include ::EachBatch diff --git a/db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb b/db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb index 3b9b95ec9ca..25c33b618ec 100644 --- a/db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb +++ b/db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb @@ -23,7 +23,7 @@ class DeleteInconsistentInternalIdRecords < ActiveRecord::Migration end end - class InternalId < ActiveRecord::Base + class InternalId < ApplicationRecord self.table_name = 'internal_ids' enum usage: { issues: 0, merge_requests: 1, deployments: 2, milestones: 3, epics: 4, ci_pipelines: 5 } end diff --git a/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb b/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb index 0a0a33299e4..cf44edac48d 100644 --- a/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb +++ b/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb @@ -7,7 +7,7 @@ class MigrateNullWikiAccessLevels < ActiveRecord::Migration disable_ddl_transaction! - class ProjectFeature < ActiveRecord::Base + class ProjectFeature < ApplicationRecord include EachBatch self.table_name = 'project_features' diff --git a/db/post_migrate/20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb b/db/post_migrate/20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb index 2dd711e9c10..d2598c3aa06 100644 --- a/db/post_migrate/20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb +++ b/db/post_migrate/20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb @@ -7,7 +7,7 @@ class MigrateLegacyArtifactsToJobArtifacts < ActiveRecord::Migration disable_ddl_transaction! - class Build < ActiveRecord::Base + class Build < ApplicationRecord include EachBatch self.table_name = 'ci_builds' diff --git a/db/post_migrate/20180906051323_remove_orphaned_label_links.rb b/db/post_migrate/20180906051323_remove_orphaned_label_links.rb index b56b74f483e..8659ce4bfef 100644 --- a/db/post_migrate/20180906051323_remove_orphaned_label_links.rb +++ b/db/post_migrate/20180906051323_remove_orphaned_label_links.rb @@ -7,7 +7,7 @@ class RemoveOrphanedLabelLinks < ActiveRecord::Migration disable_ddl_transaction! - class LabelLinks < ActiveRecord::Base + class LabelLinks < ApplicationRecord self.table_name = 'label_links' include EachBatch diff --git a/db/post_migrate/20180913142237_schedule_digest_personal_access_tokens.rb b/db/post_migrate/20180913142237_schedule_digest_personal_access_tokens.rb index 36be819b245..86da4787962 100644 --- a/db/post_migrate/20180913142237_schedule_digest_personal_access_tokens.rb +++ b/db/post_migrate/20180913142237_schedule_digest_personal_access_tokens.rb @@ -9,7 +9,7 @@ class ScheduleDigestPersonalAccessTokens < ActiveRecord::Migration disable_ddl_transaction! - class PersonalAccessToken < ActiveRecord::Base + class PersonalAccessToken < ApplicationRecord include EachBatch self.table_name = 'personal_access_tokens' diff --git a/db/post_migrate/20180916014356_populate_external_pipeline_source.rb b/db/post_migrate/20180916014356_populate_external_pipeline_source.rb index 5577d05cf40..19c5e01db84 100644 --- a/db/post_migrate/20180916014356_populate_external_pipeline_source.rb +++ b/db/post_migrate/20180916014356_populate_external_pipeline_source.rb @@ -13,7 +13,7 @@ class PopulateExternalPipelineSource < ActiveRecord::Migration disable_ddl_transaction! - class Pipeline < ActiveRecord::Base + class Pipeline < ApplicationRecord include EachBatch self.table_name = 'ci_pipelines' end diff --git a/db/post_migrate/20181014121030_enqueue_redact_links.rb b/db/post_migrate/20181014121030_enqueue_redact_links.rb index 1ee4703c88a..e68a6c3ca7e 100644 --- a/db/post_migrate/20181014121030_enqueue_redact_links.rb +++ b/db/post_migrate/20181014121030_enqueue_redact_links.rb @@ -10,28 +10,28 @@ class EnqueueRedactLinks < ActiveRecord::Migration disable_ddl_transaction! - class Note < ActiveRecord::Base + class Note < ApplicationRecord include EachBatch self.table_name = 'notes' self.inheritance_column = :_type_disabled end - class Issue < ActiveRecord::Base + class Issue < ApplicationRecord include EachBatch self.table_name = 'issues' self.inheritance_column = :_type_disabled end - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord include EachBatch self.table_name = 'merge_requests' self.inheritance_column = :_type_disabled end - class Snippet < ActiveRecord::Base + class Snippet < ApplicationRecord include EachBatch self.table_name = 'snippets' diff --git a/db/post_migrate/20181030135124_fill_empty_finished_at_in_deployments.rb b/db/post_migrate/20181030135124_fill_empty_finished_at_in_deployments.rb index 32b271c472a..ae5836c83c6 100644 --- a/db/post_migrate/20181030135124_fill_empty_finished_at_in_deployments.rb +++ b/db/post_migrate/20181030135124_fill_empty_finished_at_in_deployments.rb @@ -6,7 +6,7 @@ class FillEmptyFinishedAtInDeployments < ActiveRecord::Migration DOWNTIME = false DEPLOYMENT_STATUS_SUCCESS = 2 # Equivalent to Deployment.statuses[:success] - class Deployments < ActiveRecord::Base + class Deployments < ApplicationRecord self.table_name = 'deployments' include EachBatch diff --git a/db/post_migrate/20181105201455_steal_fill_store_upload.rb b/db/post_migrate/20181105201455_steal_fill_store_upload.rb index 982001fedbe..5cdd9f23bb6 100644 --- a/db/post_migrate/20181105201455_steal_fill_store_upload.rb +++ b/db/post_migrate/20181105201455_steal_fill_store_upload.rb @@ -8,7 +8,7 @@ class StealFillStoreUpload < ActiveRecord::Migration disable_ddl_transaction! - class Upload < ActiveRecord::Base + class Upload < ApplicationRecord include EachBatch self.table_name = 'uploads' diff --git a/db/post_migrate/20181107054254_remove_restricted_todos_again.rb b/db/post_migrate/20181107054254_remove_restricted_todos_again.rb index 644e0074c46..de63ac400ca 100644 --- a/db/post_migrate/20181107054254_remove_restricted_todos_again.rb +++ b/db/post_migrate/20181107054254_remove_restricted_todos_again.rb @@ -11,7 +11,7 @@ class RemoveRestrictedTodosAgain < ActiveRecord::Migration BATCH_SIZE = 1000 DELAY_INTERVAL = 5.minutes.to_i - class Project < ActiveRecord::Base + class Project < ApplicationRecord include EachBatch self.table_name = 'projects' diff --git a/lib/after_commit_queue.rb b/lib/after_commit_queue.rb index 6fb7985f955..3e4c56844de 100644 --- a/lib/after_commit_queue.rb +++ b/lib/after_commit_queue.rb @@ -16,7 +16,7 @@ module AfterCommitQueue def run_after_commit_or_now(&block) if AfterCommitQueue.inside_transaction? - if ActiveRecord::Base.connection.current_transaction.records.include?(self) + if ApplicationRecord.connection.current_transaction.records.include?(self) run_after_commit(&block) else # If the current transaction does not include this record, we can run @@ -41,7 +41,7 @@ module AfterCommitQueue end def self.inside_transaction? - ActiveRecord::Base.connection.open_transactions > open_transactions_baseline + ApplicationRecord.connection.open_transactions > open_transactions_baseline end protected diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb index a0434a66ef1..f8336999177 100644 --- a/lib/backup/manager.rb +++ b/lib/backup/manager.rb @@ -14,7 +14,7 @@ module Backup def pack # Make sure there is a connection - ActiveRecord::Base.connection.reconnect! + ApplicationRecord.connection.reconnect! Dir.chdir(backup_path) do File.open("#{backup_path}/backup_information.yml", "w+") do |file| diff --git a/lib/gitlab/background_migration/add_merge_request_diff_commits_count.rb b/lib/gitlab/background_migration/add_merge_request_diff_commits_count.rb index cb2bdea755c..5d9d426a3cc 100644 --- a/lib/gitlab/background_migration/add_merge_request_diff_commits_count.rb +++ b/lib/gitlab/background_migration/add_merge_request_diff_commits_count.rb @@ -4,7 +4,7 @@ module Gitlab module BackgroundMigration class AddMergeRequestDiffCommitsCount - class MergeRequestDiff < ActiveRecord::Base + class MergeRequestDiff < ApplicationRecord self.table_name = 'merge_request_diffs' end diff --git a/lib/gitlab/background_migration/cleanup_concurrent_schema_change.rb b/lib/gitlab/background_migration/cleanup_concurrent_schema_change.rb index 54f77f184d5..d59a449994d 100644 --- a/lib/gitlab/background_migration/cleanup_concurrent_schema_change.rb +++ b/lib/gitlab/background_migration/cleanup_concurrent_schema_change.rb @@ -31,7 +31,7 @@ module Gitlab # These methods are necessary so we can re-use the migration helpers in # this class. def connection - ActiveRecord::Base.connection + ApplicationRecord.connection end def method_missing(name, *args, &block) @@ -43,7 +43,7 @@ module Gitlab end def define_model_for(table) - Class.new(ActiveRecord::Base) do + Class.new(ApplicationRecord) do self.table_name = table end end diff --git a/lib/gitlab/background_migration/copy_column.rb b/lib/gitlab/background_migration/copy_column.rb index ef70f37d5eb..66a5706ba68 100644 --- a/lib/gitlab/background_migration/copy_column.rb +++ b/lib/gitlab/background_migration/copy_column.rb @@ -34,7 +34,7 @@ module Gitlab end def connection - ActiveRecord::Base.connection + ApplicationRecord.connection end end end diff --git a/lib/gitlab/background_migration/create_fork_network_memberships_range.rb b/lib/gitlab/background_migration/create_fork_network_memberships_range.rb index ccd1f9b4dba..961653a70a0 100644 --- a/lib/gitlab/background_migration/create_fork_network_memberships_range.rb +++ b/lib/gitlab/background_migration/create_fork_network_memberships_range.rb @@ -6,7 +6,7 @@ module Gitlab class CreateForkNetworkMembershipsRange RESCHEDULE_DELAY = 15 - class ForkedProjectLink < ActiveRecord::Base + class ForkedProjectLink < ApplicationRecord self.table_name = 'forked_project_links' end @@ -21,7 +21,7 @@ module Gitlab end def insert_members(start_id, end_id) - ActiveRecord::Base.connection.execute <<~INSERT_MEMBERS + ApplicationRecord.connection.execute <<~INSERT_MEMBERS INSERT INTO fork_network_members (fork_network_id, project_id, forked_from_project_id) SELECT fork_network_members.fork_network_id, diff --git a/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys.rb b/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys.rb index da8265a3a5f..94be65d1217 100644 --- a/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys.rb +++ b/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys.rb @@ -2,7 +2,7 @@ # rubocop:disable Style/Documentation class Gitlab::BackgroundMigration::CreateGpgKeySubkeysFromGpgKeys - class GpgKey < ActiveRecord::Base + class GpgKey < ApplicationRecord self.table_name = 'gpg_keys' include EachBatch @@ -14,7 +14,7 @@ class Gitlab::BackgroundMigration::CreateGpgKeySubkeysFromGpgKeys has_many :subkeys, class_name: 'GpgKeySubkey' end - class GpgKeySubkey < ActiveRecord::Base + class GpgKeySubkey < ApplicationRecord self.table_name = 'gpg_key_subkeys' include ShaAttribute diff --git a/lib/gitlab/background_migration/delete_diff_files.rb b/lib/gitlab/background_migration/delete_diff_files.rb index 664ead1af44..b80ae9d8721 100644 --- a/lib/gitlab/background_migration/delete_diff_files.rb +++ b/lib/gitlab/background_migration/delete_diff_files.rb @@ -4,14 +4,14 @@ module Gitlab module BackgroundMigration class DeleteDiffFiles - class MergeRequestDiff < ActiveRecord::Base + class MergeRequestDiff < ApplicationRecord self.table_name = 'merge_request_diffs' belongs_to :merge_request has_many :merge_request_diff_files end - class MergeRequestDiffFile < ActiveRecord::Base + class MergeRequestDiffFile < ApplicationRecord self.table_name = 'merge_request_diff_files' end @@ -70,7 +70,7 @@ module Gitlab end def execute_statement(sql) - ActiveRecord::Base.connection.execute(sql) + ApplicationRecord.connection.execute(sql) end def log_info(message) diff --git a/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits.rb b/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits.rb index 58df74cfa9b..5fd5c93934b 100644 --- a/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits.rb +++ b/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits.rb @@ -14,7 +14,7 @@ module Gitlab end end - class MergeRequestDiff < ActiveRecord::Base + class MergeRequestDiff < ApplicationRecord self.table_name = 'merge_request_diffs' end diff --git a/lib/gitlab/background_migration/digest_column.rb b/lib/gitlab/background_migration/digest_column.rb index 22a3bb8f8f3..16d3c3df25e 100644 --- a/lib/gitlab/background_migration/digest_column.rb +++ b/lib/gitlab/background_migration/digest_column.rb @@ -4,7 +4,7 @@ module Gitlab module BackgroundMigration class DigestColumn - class PersonalAccessToken < ActiveRecord::Base + class PersonalAccessToken < ApplicationRecord self.table_name = 'personal_access_tokens' end diff --git a/lib/gitlab/background_migration/fill_file_store_job_artifact.rb b/lib/gitlab/background_migration/fill_file_store_job_artifact.rb index 103bd98af14..061a492c4a3 100644 --- a/lib/gitlab/background_migration/fill_file_store_job_artifact.rb +++ b/lib/gitlab/background_migration/fill_file_store_job_artifact.rb @@ -4,7 +4,7 @@ module Gitlab module BackgroundMigration class FillFileStoreJobArtifact - class JobArtifact < ActiveRecord::Base + class JobArtifact < ApplicationRecord self.table_name = 'ci_job_artifacts' end diff --git a/lib/gitlab/background_migration/fill_file_store_lfs_object.rb b/lib/gitlab/background_migration/fill_file_store_lfs_object.rb index 77c1f1ffaf0..8e0bceb1fa7 100644 --- a/lib/gitlab/background_migration/fill_file_store_lfs_object.rb +++ b/lib/gitlab/background_migration/fill_file_store_lfs_object.rb @@ -4,7 +4,7 @@ module Gitlab module BackgroundMigration class FillFileStoreLfsObject - class LfsObject < ActiveRecord::Base + class LfsObject < ApplicationRecord self.table_name = 'lfs_objects' end diff --git a/lib/gitlab/background_migration/fill_store_upload.rb b/lib/gitlab/background_migration/fill_store_upload.rb index cba3e21cea6..0754141f6c7 100644 --- a/lib/gitlab/background_migration/fill_store_upload.rb +++ b/lib/gitlab/background_migration/fill_store_upload.rb @@ -4,7 +4,7 @@ module Gitlab module BackgroundMigration class FillStoreUpload - class Upload < ActiveRecord::Base + class Upload < ApplicationRecord self.table_name = 'uploads' self.inheritance_column = :_type_disabled end diff --git a/lib/gitlab/background_migration/fix_cross_project_label_links.rb b/lib/gitlab/background_migration/fix_cross_project_label_links.rb index 0a12401c35f..7c043b4037e 100644 --- a/lib/gitlab/background_migration/fix_cross_project_label_links.rb +++ b/lib/gitlab/background_migration/fix_cross_project_label_links.rb @@ -6,28 +6,28 @@ module Gitlab class FixCrossProjectLabelLinks GROUP_NESTED_LEVEL = 10.freeze - class Project < ActiveRecord::Base + class Project < ApplicationRecord self.table_name = 'projects' end - class Label < ActiveRecord::Base + class Label < ApplicationRecord self.inheritance_column = :_type_disabled self.table_name = 'labels' end - class LabelLink < ActiveRecord::Base + class LabelLink < ApplicationRecord self.table_name = 'label_links' end - class Issue < ActiveRecord::Base + class Issue < ApplicationRecord self.table_name = 'issues' end - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord self.table_name = 'merge_requests' end - class Namespace < ActiveRecord::Base + class Namespace < ApplicationRecord self.inheritance_column = :_type_disabled self.table_name = 'namespaces' diff --git a/lib/gitlab/background_migration/migrate_build_stage.rb b/lib/gitlab/background_migration/migrate_build_stage.rb index 268c6083d3c..2a28f28d7b7 100644 --- a/lib/gitlab/background_migration/migrate_build_stage.rb +++ b/lib/gitlab/background_migration/migrate_build_stage.rb @@ -5,11 +5,11 @@ module Gitlab module BackgroundMigration class MigrateBuildStage module Migratable - class Stage < ActiveRecord::Base + class Stage < ApplicationRecord self.table_name = 'ci_stages' end - class Build < ActiveRecord::Base + class Build < ApplicationRecord self.table_name = 'ci_builds' self.inheritance_column = :_type_disabled diff --git a/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb b/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb index 0a8a4313cd5..db2d10f67a2 100644 --- a/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb +++ b/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb @@ -15,7 +15,7 @@ module Gitlab AND ci_builds.stage_id IS NULL SQL - ActiveRecord::Base.connection.execute(sql) + ApplicationRecord.connection.execute(sql) end end end diff --git a/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb b/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb index 38fecac1bfe..3f51413d02e 100644 --- a/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb +++ b/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb @@ -7,7 +7,7 @@ module Gitlab # events are copied to a shadow table, and push events will also have a row # created in the push_event_payloads table. class MigrateEventsToPushEventPayloads - class Event < ActiveRecord::Base + class Event < ApplicationRecord self.table_name = 'events' serialize :data @@ -99,11 +99,11 @@ module Gitlab end end - class EventForMigration < ActiveRecord::Base + class EventForMigration < ApplicationRecord self.table_name = 'events_for_migration' end - class PushEventPayload < ActiveRecord::Base + class PushEventPayload < ApplicationRecord self.table_name = 'push_event_payloads' enum action: { @@ -127,7 +127,7 @@ module Gitlab end def process_event(event) - ActiveRecord::Base.transaction do + ApplicationRecord.transaction do replicate_event(event) create_push_event_payload(event) if event.push_event? end diff --git a/lib/gitlab/background_migration/migrate_legacy_artifacts.rb b/lib/gitlab/background_migration/migrate_legacy_artifacts.rb index 5cd638083b0..6b054f9341f 100644 --- a/lib/gitlab/background_migration/migrate_legacy_artifacts.rb +++ b/lib/gitlab/background_migration/migrate_legacy_artifacts.rb @@ -12,7 +12,7 @@ module Gitlab LEGACY_PATH_FILE_LOCATION = 1 # equal to Ci::JobArtifact.file_location['legacy_path'] def perform(start_id, stop_id) - ActiveRecord::Base.transaction do + ApplicationRecord.transaction do insert_archives(start_id, stop_id) insert_metadatas(start_id, stop_id) delete_legacy_artifacts(start_id, stop_id) @@ -22,7 +22,7 @@ module Gitlab private def insert_archives(start_id, stop_id) - ActiveRecord::Base.connection.execute <<~SQL + ApplicationRecord.connection.execute <<~SQL INSERT INTO ci_job_artifacts ( project_id, @@ -64,7 +64,7 @@ module Gitlab end def insert_metadatas(start_id, stop_id) - ActiveRecord::Base.connection.execute <<~SQL + ApplicationRecord.connection.execute <<~SQL INSERT INTO ci_job_artifacts ( project_id, @@ -107,7 +107,7 @@ module Gitlab end def delete_legacy_artifacts(start_id, stop_id) - ActiveRecord::Base.connection.execute <<~SQL + ApplicationRecord.connection.execute <<~SQL UPDATE ci_builds SET diff --git a/lib/gitlab/background_migration/migrate_stage_index.rb b/lib/gitlab/background_migration/migrate_stage_index.rb index f90f35a913d..798926970d5 100644 --- a/lib/gitlab/background_migration/migrate_stage_index.rb +++ b/lib/gitlab/background_migration/migrate_stage_index.rb @@ -6,7 +6,7 @@ module Gitlab class MigrateStageIndex def perform(start_id, stop_id) migrate_stage_index_sql(start_id.to_i, stop_id.to_i).tap do |sql| - ActiveRecord::Base.connection.execute(sql) + ApplicationRecord.connection.execute(sql) end end diff --git a/lib/gitlab/background_migration/migrate_stage_status.rb b/lib/gitlab/background_migration/migrate_stage_status.rb index 0e5c7f092f2..d0361561222 100644 --- a/lib/gitlab/background_migration/migrate_stage_status.rb +++ b/lib/gitlab/background_migration/migrate_stage_status.rb @@ -8,7 +8,7 @@ module Gitlab STATUSES = { created: 0, pending: 1, running: 2, success: 3, failed: 4, canceled: 5, skipped: 6, manual: 7 }.freeze - class Build < ActiveRecord::Base + class Build < ApplicationRecord self.table_name = 'ci_builds' scope :latest, -> { where(retried: [false, nil]) } @@ -74,7 +74,7 @@ module Gitlab AND ci_stages.id BETWEEN #{start_id.to_i} AND #{stop_id.to_i} SQL - ActiveRecord::Base.connection.execute(sql) + ApplicationRecord.connection.execute(sql) end end end diff --git a/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb b/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb index ef50fe4adb1..64f97c5753c 100644 --- a/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb +++ b/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb @@ -7,7 +7,7 @@ module Gitlab include Gitlab::Database::MigrationHelpers attr_reader :old_folder, :new_folder - class Upload < ActiveRecord::Base + class Upload < ApplicationRecord self.table_name = 'uploads' include EachBatch end diff --git a/lib/gitlab/background_migration/models/encrypt_columns/web_hook.rb b/lib/gitlab/background_migration/models/encrypt_columns/web_hook.rb index bb76eb8ed48..3183b135ca5 100644 --- a/lib/gitlab/background_migration/models/encrypt_columns/web_hook.rb +++ b/lib/gitlab/background_migration/models/encrypt_columns/web_hook.rb @@ -6,7 +6,7 @@ module Gitlab module EncryptColumns # This model is shared between synchronous and background migrations to # encrypt the `token` and `url` columns - class WebHook < ActiveRecord::Base + class WebHook < ApplicationRecord include ::EachBatch self.table_name = 'web_hooks' diff --git a/lib/gitlab/background_migration/move_personal_snippet_files.rb b/lib/gitlab/background_migration/move_personal_snippet_files.rb index 5b2b2af718a..154ece36cb2 100644 --- a/lib/gitlab/background_migration/move_personal_snippet_files.rb +++ b/lib/gitlab/background_migration/move_personal_snippet_files.rb @@ -71,7 +71,7 @@ module Gitlab end def connection - ActiveRecord::Base.connection + ApplicationRecord.connection end def say(message) diff --git a/lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb b/lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb index 698f5e46c0c..ea2b39626f3 100644 --- a/lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb +++ b/lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb @@ -7,7 +7,7 @@ module Gitlab module BackgroundMigration class NormalizeLdapExternUidsRange - class Identity < ActiveRecord::Base + class Identity < ApplicationRecord self.table_name = 'identities' end diff --git a/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table.rb b/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table.rb index 35bfc381180..f00edd60649 100644 --- a/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table.rb +++ b/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table.rb @@ -10,11 +10,11 @@ module Gitlab BATCH_SIZE = 1_000 module Migratable - class KubernetesNamespace < ActiveRecord::Base + class KubernetesNamespace < ApplicationRecord self.table_name = 'clusters_kubernetes_namespaces' end - class ClusterProject < ActiveRecord::Base + class ClusterProject < ApplicationRecord include EachBatch self.table_name = 'cluster_projects' @@ -35,7 +35,7 @@ module Gitlab end end - class Project < ActiveRecord::Base + class Project < ApplicationRecord self.table_name = 'projects' end end diff --git a/lib/gitlab/background_migration/populate_external_pipeline_source.rb b/lib/gitlab/background_migration/populate_external_pipeline_source.rb index 036fe641757..56d6e68f078 100644 --- a/lib/gitlab/background_migration/populate_external_pipeline_source.rb +++ b/lib/gitlab/background_migration/populate_external_pipeline_source.rb @@ -5,7 +5,7 @@ module Gitlab module BackgroundMigration class PopulateExternalPipelineSource module Migratable - class Pipeline < ActiveRecord::Base + class Pipeline < ApplicationRecord self.table_name = 'ci_pipelines' def self.sources @@ -21,7 +21,7 @@ module Gitlab end end - class CommitStatus < ActiveRecord::Base + class CommitStatus < ApplicationRecord self.table_name = 'ci_builds' self.inheritance_column = :_type_disabled diff --git a/lib/gitlab/background_migration/populate_fork_networks_range.rb b/lib/gitlab/background_migration/populate_fork_networks_range.rb index aa4f130538c..d93bdbf3554 100644 --- a/lib/gitlab/background_migration/populate_fork_networks_range.rb +++ b/lib/gitlab/background_migration/populate_fork_networks_range.rb @@ -27,7 +27,7 @@ module Gitlab def create_fork_networks_for_existing_projects(start_id, end_id) log("Creating fork networks: #{start_id} - #{end_id}") - ActiveRecord::Base.connection.execute <<~INSERT_NETWORKS + ApplicationRecord.connection.execute <<~INSERT_NETWORKS INSERT INTO fork_networks (root_project_id) SELECT DISTINCT forked_project_links.forked_from_project_id @@ -61,7 +61,7 @@ module Gitlab def create_fork_networks_for_missing_projects(start_id, end_id) log("Creating fork networks with missing root: #{start_id} - #{end_id}") - ActiveRecord::Base.connection.execute <<~INSERT_NETWORKS + ApplicationRecord.connection.execute <<~INSERT_NETWORKS INSERT INTO fork_networks (root_project_id) SELECT DISTINCT forked_project_links.forked_to_project_id @@ -98,7 +98,7 @@ module Gitlab def create_fork_networks_memberships_for_root_projects(start_id, end_id) log("Creating memberships for root projects: #{start_id} - #{end_id}") - ActiveRecord::Base.connection.execute <<~INSERT_ROOT + ApplicationRecord.connection.execute <<~INSERT_ROOT INSERT INTO fork_network_members (fork_network_id, project_id) SELECT DISTINCT fork_networks.id, fork_networks.root_project_id diff --git a/lib/gitlab/background_migration/populate_import_state.rb b/lib/gitlab/background_migration/populate_import_state.rb index 695a2a713c5..5ddd403c163 100644 --- a/lib/gitlab/background_migration/populate_import_state.rb +++ b/lib/gitlab/background_migration/populate_import_state.rb @@ -14,7 +14,7 @@ module Gitlab def move_attributes_data_to_import_state(start_id, end_id) Rails.logger.info("#{self.class.name} - Moving import attributes data to project mirror data table: #{start_id} - #{end_id}") - ActiveRecord::Base.connection.execute <<~SQL + ApplicationRecord.connection.execute <<~SQL INSERT INTO project_mirror_data (project_id, status, jid, last_error) SELECT id, import_status, import_jid, import_error FROM projects @@ -27,7 +27,7 @@ module Gitlab ) SQL - ActiveRecord::Base.connection.execute <<~SQL + ApplicationRecord.connection.execute <<~SQL UPDATE projects SET import_status = 'none' WHERE import_status != 'none' diff --git a/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data.rb b/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data.rb index d89ce358bb9..2ad2819ce61 100644 --- a/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data.rb +++ b/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data.rb @@ -92,7 +92,7 @@ module Gitlab end def execute(sql) - @connection ||= ActiveRecord::Base.connection + @connection ||= ApplicationRecord.connection @connection.execute(sql) end diff --git a/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id.rb b/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id.rb index dcac355e1b0..b3292ca4c9c 100644 --- a/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id.rb +++ b/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id.rb @@ -6,7 +6,7 @@ module Gitlab class PopulateMergeRequestsLatestMergeRequestDiffId BATCH_SIZE = 1_000 - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord self.table_name = 'merge_requests' include ::EachBatch diff --git a/lib/gitlab/background_migration/populate_untracked_uploads_dependencies.rb b/lib/gitlab/background_migration/populate_untracked_uploads_dependencies.rb index 4a9a62aaeb5..7df25d430ef 100644 --- a/lib/gitlab/background_migration/populate_untracked_uploads_dependencies.rb +++ b/lib/gitlab/background_migration/populate_untracked_uploads_dependencies.rb @@ -4,7 +4,7 @@ module Gitlab module PopulateUntrackedUploadsDependencies # This class is responsible for producing the attributes necessary to # track an uploaded file in the `uploads` table. - class UntrackedFile < ActiveRecord::Base # rubocop:disable Metrics/ClassLength + class UntrackedFile < ApplicationRecord # rubocop:disable Metrics/ClassLength self.table_name = 'untracked_files_for_uploads' # Ends with /:random_hex/:filename @@ -145,34 +145,34 @@ module Gitlab end # Avoid using application code - class Upload < ActiveRecord::Base + class Upload < ApplicationRecord self.table_name = 'uploads' end # Avoid using application code - class Appearance < ActiveRecord::Base + class Appearance < ApplicationRecord self.table_name = 'appearances' end # Avoid using application code - class Namespace < ActiveRecord::Base + class Namespace < ApplicationRecord self.table_name = 'namespaces' end # Avoid using application code - class Note < ActiveRecord::Base + class Note < ApplicationRecord self.table_name = 'notes' end # Avoid using application code - class User < ActiveRecord::Base + class User < ApplicationRecord self.table_name = 'users' end # Since project Markdown upload paths don't contain the project ID, we have to find the # project by its full_path. Due to MySQL/PostgreSQL differences, and historical reasons, # the logic is somewhat complex, so I've mostly copied it in here. - class Project < ActiveRecord::Base + class Project < ApplicationRecord self.table_name = 'projects' def self.find_by_full_path(path) diff --git a/lib/gitlab/background_migration/prepare_untracked_uploads.rb b/lib/gitlab/background_migration/prepare_untracked_uploads.rb index 81ca2b0a9b7..c9a673556e2 100644 --- a/lib/gitlab/background_migration/prepare_untracked_uploads.rb +++ b/lib/gitlab/background_migration/prepare_untracked_uploads.rb @@ -22,7 +22,7 @@ module Gitlab # This class is used to iterate over batches of # `untracked_files_for_uploads` rows. - class UntrackedFile < ActiveRecord::Base + class UntrackedFile < ApplicationRecord include EachBatch self.table_name = 'untracked_files_for_uploads' @@ -55,7 +55,7 @@ module Gitlab def ensure_temporary_tracking_table_exists table_name = :untracked_files_for_uploads - unless ActiveRecord::Base.connection.data_source_exists?(table_name) + unless ApplicationRecord.connection.data_source_exists?(table_name) UntrackedFile.connection.create_table table_name do |t| t.string :path, limit: 600, null: false t.index :path, unique: true @@ -127,7 +127,7 @@ module Gitlab def insert_file_paths(file_paths) sql = insert_sql(file_paths) - ActiveRecord::Base.connection.execute(sql) + ApplicationRecord.connection.execute(sql) end def insert_sql(file_paths) @@ -144,7 +144,7 @@ module Gitlab def table_columns_and_values_for_insert(file_paths) values = file_paths.map do |file_path| - ActiveRecord::Base.send(:sanitize_sql_array, ['(?)', file_path]) # rubocop:disable GitlabSecurity/PublicSend + ApplicationRecord.send(:sanitize_sql_array, ['(?)', file_path]) # rubocop:disable GitlabSecurity/PublicSend end.join(', ') "#{UntrackedFile.table_name} (path) VALUES #{values}" diff --git a/lib/gitlab/background_migration/redact_links.rb b/lib/gitlab/background_migration/redact_links.rb index 92256e59a6c..1f70e2be9fc 100644 --- a/lib/gitlab/background_migration/redact_links.rb +++ b/lib/gitlab/background_migration/redact_links.rb @@ -6,7 +6,7 @@ require_relative 'redact_links/redactable' module Gitlab module BackgroundMigration class RedactLinks - class Note < ActiveRecord::Base + class Note < ApplicationRecord include EachBatch include ::Gitlab::BackgroundMigration::RedactLinks::Redactable @@ -14,7 +14,7 @@ module Gitlab self.inheritance_column = :_type_disabled end - class Issue < ActiveRecord::Base + class Issue < ApplicationRecord include EachBatch include ::Gitlab::BackgroundMigration::RedactLinks::Redactable @@ -22,7 +22,7 @@ module Gitlab self.inheritance_column = :_type_disabled end - class MergeRequest < ActiveRecord::Base + class MergeRequest < ApplicationRecord include EachBatch include ::Gitlab::BackgroundMigration::RedactLinks::Redactable @@ -30,7 +30,7 @@ module Gitlab self.inheritance_column = :_type_disabled end - class Snippet < ActiveRecord::Base + class Snippet < ApplicationRecord include EachBatch include ::Gitlab::BackgroundMigration::RedactLinks::Redactable diff --git a/lib/gitlab/background_migration/remove_restricted_todos.rb b/lib/gitlab/background_migration/remove_restricted_todos.rb index 47579d46c1b..4408ef76119 100644 --- a/lib/gitlab/background_migration/remove_restricted_todos.rb +++ b/lib/gitlab/background_migration/remove_restricted_todos.rb @@ -8,25 +8,25 @@ module Gitlab PRIVATE_FEATURE = 10 PRIVATE_PROJECT = 0 - class Project < ActiveRecord::Base + class Project < ApplicationRecord self.table_name = 'projects' end - class ProjectAuthorization < ActiveRecord::Base + class ProjectAuthorization < ApplicationRecord self.table_name = 'project_authorizations' end - class ProjectFeature < ActiveRecord::Base + class ProjectFeature < ApplicationRecord self.table_name = 'project_features' end - class Todo < ActiveRecord::Base + class Todo < ApplicationRecord include EachBatch self.table_name = 'todos' end - class Issue < ActiveRecord::Base + class Issue < ApplicationRecord include EachBatch self.table_name = 'issues' diff --git a/lib/gitlab/background_migration/rollback_import_state_data.rb b/lib/gitlab/background_migration/rollback_import_state_data.rb index a7c986747d8..29e98baf441 100644 --- a/lib/gitlab/background_migration/rollback_import_state_data.rb +++ b/lib/gitlab/background_migration/rollback_import_state_data.rb @@ -13,7 +13,7 @@ module Gitlab Rails.logger.info("#{self.class.name} - Moving import attributes data to projects table: #{start_id} - #{end_id}") if Gitlab::Database.mysql? - ActiveRecord::Base.connection.execute <<~SQL + ApplicationRecord.connection.execute <<~SQL UPDATE projects, project_mirror_data SET projects.import_status = project_mirror_data.status, @@ -23,7 +23,7 @@ module Gitlab AND project_mirror_data.id BETWEEN #{start_id} AND #{end_id} SQL else - ActiveRecord::Base.connection.execute <<~SQL + ApplicationRecord.connection.execute <<~SQL UPDATE projects SET import_status = project_mirror_data.status, diff --git a/lib/gitlab/background_migration/schedule_diff_files_deletion.rb b/lib/gitlab/background_migration/schedule_diff_files_deletion.rb index 609cf19187c..58717af215a 100644 --- a/lib/gitlab/background_migration/schedule_diff_files_deletion.rb +++ b/lib/gitlab/background_migration/schedule_diff_files_deletion.rb @@ -4,7 +4,7 @@ module Gitlab module BackgroundMigration class ScheduleDiffFilesDeletion - class MergeRequestDiff < ActiveRecord::Base + class MergeRequestDiff < ApplicationRecord self.table_name = 'merge_request_diffs' belongs_to :merge_request diff --git a/lib/gitlab/background_migration/set_confidential_note_events_on_services.rb b/lib/gitlab/background_migration/set_confidential_note_events_on_services.rb index bc434b0cb64..1ea209803bb 100644 --- a/lib/gitlab/background_migration/set_confidential_note_events_on_services.rb +++ b/lib/gitlab/background_migration/set_confidential_note_events_on_services.rb @@ -6,7 +6,7 @@ module Gitlab # Ensures services which previously received all notes events continue # to receive confidential ones. class SetConfidentialNoteEventsOnServices - class Service < ActiveRecord::Base + class Service < ApplicationRecord self.table_name = 'services' include ::EachBatch diff --git a/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks.rb b/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks.rb index 28d8d2c640b..c93117fa79e 100644 --- a/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks.rb +++ b/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks.rb @@ -6,7 +6,7 @@ module Gitlab # Ensures hooks which previously received all notes events continue # to receive confidential ones. class SetConfidentialNoteEventsOnWebhooks - class WebHook < ActiveRecord::Base + class WebHook < ApplicationRecord self.table_name = 'web_hooks' include ::EachBatch diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index 477f9101e98..970a06df9a1 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -76,7 +76,7 @@ module Gitlab def connect_to_db? # When the DBMS is not available, an exception (e.g. PG::ConnectionBad) is raised - active_db_connection = ActiveRecord::Base.connection.active? rescue false + active_db_connection = ApplicationRecord.connection.active? rescue false active_db_connection && Gitlab::Database.cached_table_exists?('application_settings') diff --git a/lib/gitlab/cycle_analytics/base_event_fetcher.rb b/lib/gitlab/cycle_analytics/base_event_fetcher.rb index 304d60996a6..317bc66a483 100644 --- a/lib/gitlab/cycle_analytics/base_event_fetcher.rb +++ b/lib/gitlab/cycle_analytics/base_event_fetcher.rb @@ -36,7 +36,7 @@ module Gitlab end def event_result - @event_result ||= ActiveRecord::Base.connection.exec_query(events_query.to_sql).to_a + @event_result ||= ApplicationRecord.connection.exec_query(events_query.to_sql).to_a end def events_query diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb index 68ed53cf64a..c1f5611311b 100644 --- a/lib/gitlab/database.rb +++ b/lib/gitlab/database.rb @@ -12,7 +12,7 @@ module Gitlab MAX_TIMESTAMP_VALUE = Time.at((1 << 31) - 1).freeze def self.config - ActiveRecord::Base.configurations[Rails.env] + ApplicationRecord.configurations[Rails.env] end def self.username @@ -47,7 +47,7 @@ module Gitlab # check whether the underlying database is in read-only mode def self.db_read_only? if postgresql? - ActiveRecord::Base.connection.execute('SELECT pg_is_in_recovery()') + ApplicationRecord.connection.execute('SELECT pg_is_in_recovery()') .first .fetch('pg_is_in_recovery') == 't' else @@ -207,7 +207,7 @@ module Gitlab def self.create_connection_pool(pool_size, host = nil) # See activerecord-4.2.7.1/lib/active_record/connection_adapters/connection_specification.rb env = Rails.env - original_config = ActiveRecord::Base.configurations + original_config = ApplicationRecord.configurations env_config = original_config[env].merge('pool' => pool_size) env_config['host'] = host if host @@ -223,7 +223,7 @@ module Gitlab end def self.connection - ActiveRecord::Base.connection + ApplicationRecord.connection end def self.cached_column_exists?(table_name, column_name) diff --git a/lib/gitlab/database/arel_methods.rb b/lib/gitlab/database/arel_methods.rb index 991e4152dcb..65131aa5f4d 100644 --- a/lib/gitlab/database/arel_methods.rb +++ b/lib/gitlab/database/arel_methods.rb @@ -12,7 +12,7 @@ module Gitlab if Gitlab.rails5? Arel::UpdateManager.new else - Arel::UpdateManager.new(ActiveRecord::Base) + Arel::UpdateManager.new(ApplicationRecord) end end end diff --git a/lib/gitlab/database/count.rb b/lib/gitlab/database/count.rb index ea6529e2dc4..2ce07625223 100644 --- a/lib/gitlab/database/count.rb +++ b/lib/gitlab/database/count.rb @@ -60,8 +60,8 @@ module Gitlab # Querying tuple stats only works on the primary. Due to load # balancing, we need to ensure this query hits the load balancer. The # easiest way to do this is to start a transaction. - ActiveRecord::Base.transaction do - rows = ActiveRecord::Base.connection.select_all(query) + ApplicationRecord.transaction do + rows = ApplicationRecord.connection.select_all(query) end rows.each_with_object({}) { |row, data| data[row['table_name']] = row['estimate'].to_i } diff --git a/lib/gitlab/database/grant.rb b/lib/gitlab/database/grant.rb index 862ab96c887..18f7d25a93b 100644 --- a/lib/gitlab/database/grant.rb +++ b/lib/gitlab/database/grant.rb @@ -3,7 +3,7 @@ module Gitlab module Database # Model that can be used for querying permissions of a SQL user. - class Grant < ActiveRecord::Base + class Grant < ApplicationRecord include FromUnion self.table_name = diff --git a/lib/gitlab/database/median.rb b/lib/gitlab/database/median.rb index 0da5119a3ed..2342ab8a36d 100644 --- a/lib/gitlab/database/median.rb +++ b/lib/gitlab/database/median.rb @@ -132,7 +132,7 @@ module Gitlab def execute_queries(arel_table, query_so_far, column_sym, partition_column = nil) queries = median_queries(arel_table, query_so_far, column_sym, partition_column) - Array.wrap(queries).map { |query| ActiveRecord::Base.connection.execute(query) } + Array.wrap(queries).map { |query| ApplicationRecord.connection.execute(query) } end def average(args, as) diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index 134d1e7a724..95df525f8d2 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -696,7 +696,7 @@ module Gitlab install_rename_triggers(table, old_column, new_column) - model = Class.new(ActiveRecord::Base) do + model = Class.new(ApplicationRecord) do self.table_name = table include ::EachBatch diff --git a/lib/gitlab/database/multi_threaded_migration.rb b/lib/gitlab/database/multi_threaded_migration.rb index 1d39a3d0b57..41dad84fcd8 100644 --- a/lib/gitlab/database/multi_threaded_migration.rb +++ b/lib/gitlab/database/multi_threaded_migration.rb @@ -10,7 +10,7 @@ module Gitlab # migration methods. def connection Thread.current[MULTI_THREAD_AR_CONNECTION] || - ActiveRecord::Base.connection + ApplicationRecord.connection end # Starts a thread-pool for N threads, along with N threads each using a diff --git a/lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb b/lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb index f1dc3ed74fe..d367f9123c5 100644 --- a/lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb +++ b/lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb @@ -36,7 +36,7 @@ module Gitlab end end - class Namespace < ActiveRecord::Base + class Namespace < ApplicationRecord include MigrationClasses::Routable self.table_name = 'namespaces' self.inheritance_column = :_type_disabled @@ -57,16 +57,16 @@ module Gitlab end end - class User < ActiveRecord::Base + class User < ApplicationRecord self.table_name = 'users' end - class Route < ActiveRecord::Base + class Route < ApplicationRecord self.table_name = 'routes' belongs_to :source, polymorphic: true end - class Project < ActiveRecord::Base + class Project < ApplicationRecord include MigrationClasses::Routable has_one :route, as: :source self.table_name = 'projects' diff --git a/lib/gitlab/gitlab_import/importer.rb b/lib/gitlab/gitlab_import/importer.rb index 047487f1d24..096743c466e 100644 --- a/lib/gitlab/gitlab_import/importer.rb +++ b/lib/gitlab/gitlab_import/importer.rb @@ -15,7 +15,7 @@ module Gitlab end def execute - ActiveRecord::Base.no_touching do + ApplicationRecord.no_touching do project_identifier = CGI.escape(project.import_source) # Issues && Comments diff --git a/lib/gitlab/health_checks/db_check.rb b/lib/gitlab/health_checks/db_check.rb index 08495c0a59e..251d8eb2848 100644 --- a/lib/gitlab/health_checks/db_check.rb +++ b/lib/gitlab/health_checks/db_check.rb @@ -17,9 +17,9 @@ module Gitlab def check catch_timeout 10.seconds do if Gitlab::Database.postgresql? - ActiveRecord::Base.connection.execute('SELECT 1 as ping')&.first&.[]('ping')&.to_s + ApplicationRecord.connection.execute('SELECT 1 as ping')&.first&.[]('ping')&.to_s else - ActiveRecord::Base.connection.execute('SELECT 1 as ping')&.first&.first&.to_s + ApplicationRecord.connection.execute('SELECT 1 as ping')&.first&.first&.to_s end end end diff --git a/lib/gitlab/import_export/project_tree_restorer.rb b/lib/gitlab/import_export/project_tree_restorer.rb index 99581eb0416..093a7dbd781 100644 --- a/lib/gitlab/import_export/project_tree_restorer.rb +++ b/lib/gitlab/import_export/project_tree_restorer.rb @@ -24,8 +24,8 @@ module Gitlab @project_members = @tree_hash.delete('project_members') - ActiveRecord::Base.uncached do - ActiveRecord::Base.no_touching do + ApplicationRecord.uncached do + ApplicationRecord.no_touching do create_relations end end diff --git a/lib/gitlab/legacy_github_import/importer.rb b/lib/gitlab/legacy_github_import/importer.rb index c5bde681365..d882d19acb0 100644 --- a/lib/gitlab/legacy_github_import/importer.rb +++ b/lib/gitlab/legacy_github_import/importer.rb @@ -220,7 +220,7 @@ module Gitlab # rubocop: disable CodeReuse/ActiveRecord def create_comments(comments) - ActiveRecord::Base.no_touching do + ApplicationRecord.no_touching do comments.each do |raw| begin comment = CommentFormatter.new(project, raw, client) diff --git a/lib/gitlab/optimistic_locking.rb b/lib/gitlab/optimistic_locking.rb index ce4ba9f752b..55cefa0e4f3 100644 --- a/lib/gitlab/optimistic_locking.rb +++ b/lib/gitlab/optimistic_locking.rb @@ -5,7 +5,7 @@ module Gitlab module_function def retry_lock(subject, retries = 100, &block) - ActiveRecord::Base.transaction do + ApplicationRecord.transaction do yield(subject) end rescue ActiveRecord::StaleObjectError diff --git a/lib/gitlab/otp_key_rotator.rb b/lib/gitlab/otp_key_rotator.rb index 1d3200aa099..2ccc3fa8939 100644 --- a/lib/gitlab/otp_key_rotator.rb +++ b/lib/gitlab/otp_key_rotator.rb @@ -36,7 +36,7 @@ module Gitlab raise ArgumentError.new("New key is too short! Must be 256 bits") if new_key.size < 64 write_csv do |csv| - ActiveRecord::Base.transaction do + ApplicationRecord.transaction do User.with_two_factor.in_batches do |relation| # rubocop: disable Cop/InBatches rows = relation.pluck(:id, :encrypted_otp_secret, :encrypted_otp_secret_iv, :encrypted_otp_secret_salt) rows.each do |row| @@ -54,7 +54,7 @@ module Gitlab # rubocop: disable CodeReuse/ActiveRecord def rollback! - ActiveRecord::Base.transaction do + ApplicationRecord.transaction do CSV.foreach(filename, headers: HEADERS, return_headers: false) do |row| User.where(id: row['user_id']).update_all(encrypted_otp_secret: row['old_value']) end diff --git a/lib/gitlab/profiler.rb b/lib/gitlab/profiler.rb index 4a62f367835..8f3fb3a2995 100644 --- a/lib/gitlab/profiler.rb +++ b/lib/gitlab/profiler.rb @@ -121,19 +121,19 @@ module Gitlab def self.with_custom_logger(logger) original_colorize_logging = ActiveSupport::LogSubscriber.colorize_logging - original_activerecord_logger = ActiveRecord::Base.logger + original_activerecord_logger = ApplicationRecord.logger original_actioncontroller_logger = ActionController::Base.logger if logger ActiveSupport::LogSubscriber.colorize_logging = false - ActiveRecord::Base.logger = logger + ApplicationRecord.logger = logger ActionController::Base.logger = logger end result = yield ActiveSupport::LogSubscriber.colorize_logging = original_colorize_logging - ActiveRecord::Base.logger = original_activerecord_logger + ApplicationRecord.logger = original_activerecord_logger ActionController::Base.logger = original_actioncontroller_logger result diff --git a/lib/gitlab/sherlock/query.rb b/lib/gitlab/sherlock/query.rb index 02ddc3f47eb..237ce73c6ea 100644 --- a/lib/gitlab/sherlock/query.rb +++ b/lib/gitlab/sherlock/query.rb @@ -27,7 +27,7 @@ module Gitlab # Returns a new Query object. def self.new_with_bindings(query, bindings, started_at, finished_at) bindings.each_with_index do |(_, value), index| - quoted_value = ActiveRecord::Base.connection.quote(value) + quoted_value = ApplicationRecord.connection.quote(value) query = query.gsub("$#{index + 1}", quoted_value) end @@ -79,7 +79,7 @@ module Gitlab # Returns the query plan as a String. def explain unless @explain - ActiveRecord::Base.connection.transaction do + ApplicationRecord.connection.transaction do @explain = raw_explain(@query).values.flatten.join("\n") # Roll back any queries that mutate data so we don't mess up @@ -101,7 +101,7 @@ module Gitlab "EXPLAIN #{query};" end - ActiveRecord::Base.connection.execute(explain) + ApplicationRecord.connection.execute(explain) end def format_sql(query) diff --git a/lib/gitlab/sql/glob.rb b/lib/gitlab/sql/glob.rb index 5e89e12b2b1..86e42d58df2 100644 --- a/lib/gitlab/sql/glob.rb +++ b/lib/gitlab/sql/glob.rb @@ -15,7 +15,7 @@ module Gitlab end def q(string) - ActiveRecord::Base.connection.quote(string) + ApplicationRecord.connection.quote(string) end end end diff --git a/lib/gitlab/sql/union.rb b/lib/gitlab/sql/union.rb index c99b262f1ca..5554e7267aa 100644 --- a/lib/gitlab/sql/union.rb +++ b/lib/gitlab/sql/union.rb @@ -22,7 +22,7 @@ module Gitlab # aren't incremented properly when joining relations together this way. # By using "unprepared_statements" we remove the usage of placeholders # (thus fixing this problem), at a slight performance cost. - fragments = ActiveRecord::Base.connection.unprepared_statement do + fragments = ApplicationRecord.connection.unprepared_statement do @relations.map { |rel| rel.reorder(nil).to_sql }.reject(&:blank?) end diff --git a/lib/system_check/orphans/repository_check.rb b/lib/system_check/orphans/repository_check.rb index ef8fe945f61..b8609a97446 100644 --- a/lib/system_check/orphans/repository_check.rb +++ b/lib/system_check/orphans/repository_check.rb @@ -58,8 +58,8 @@ module SystemCheck WHERE (p.repository_storage LIKE ?) " - query = ActiveRecord::Base.send(:sanitize_sql_array, [sql, storage_name]) # rubocop:disable GitlabSecurity/PublicSend - ActiveRecord::Base.connection.select_all(query).rows.try(:flatten!) || [] + query = ApplicationRecord.send(:sanitize_sql_array, [sql, storage_name]) # rubocop:disable GitlabSecurity/PublicSend + ApplicationRecord.connection.select_all(query).rows.try(:flatten!) || [] end def fetch_disk_namespaces(storage_path) diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake index 74cd70c6e9f..22a9ed33150 100644 --- a/lib/tasks/gitlab/db.rake +++ b/lib/tasks/gitlab/db.rake @@ -15,7 +15,7 @@ namespace :gitlab do sql = "INSERT INTO schema_migrations (version) VALUES (#{version})" begin - ActiveRecord::Base.connection.execute(sql) + ApplicationRecord.connection.execute(sql) puts "Successfully marked '#{version}' as complete".color(:green) rescue ActiveRecord::RecordNotUnique puts "Migration version '#{version}' is already marked complete".color(:yellow) @@ -24,7 +24,7 @@ namespace :gitlab do desc 'Drop all tables' task drop_tables: :environment do - connection = ActiveRecord::Base.connection + connection = ApplicationRecord.connection # If MySQL, turn off foreign key checks connection.execute('SET FOREIGN_KEY_CHECKS=0') if Gitlab::Database.mysql? @@ -48,7 +48,7 @@ namespace :gitlab do task configure: :environment do # Check if we have existing db tables # The schema_migrations table will still exist if drop_tables was called - if ActiveRecord::Base.connection.tables.count > 1 + if ApplicationRecord.connection.tables.count > 1 Rake::Task['db:migrate'].invoke else # Add post-migrate paths to ensure we mark all migrations as up diff --git a/lib/tasks/gitlab/info.rake b/lib/tasks/gitlab/info.rake index e97d77d20e0..6fad2cb9887 100644 --- a/lib/tasks/gitlab/info.rake +++ b/lib/tasks/gitlab/info.rake @@ -35,7 +35,7 @@ namespace :gitlab do puts "Go Version:\t#{go_version[1] || "unknown".color(:red)}" # check database adapter - database_adapter = ActiveRecord::Base.connection.adapter_name.downcase + database_adapter = ApplicationRecord.connection.adapter_name.downcase project = Group.new(path: "some-group").projects.build(path: "some-project") # construct clone URLs diff --git a/lib/tasks/gitlab/site_statistics.rake b/lib/tasks/gitlab/site_statistics.rake index d97f11b2ed5..8912bf8ff17 100644 --- a/lib/tasks/gitlab/site_statistics.rake +++ b/lib/tasks/gitlab/site_statistics.rake @@ -6,7 +6,7 @@ namespace :gitlab do print '* Repositories... ' SiteStatistic.transaction do # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967 - ActiveRecord::Base.connection.execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? + ApplicationRecord.connection.execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? SiteStatistic.update_all('repositories_count = (SELECT COUNT(*) FROM projects)') end puts 'OK!'.color(:green) diff --git a/lib/tasks/tokens.rake b/lib/tasks/tokens.rake index eec024f9bbb..efc44e05fd3 100644 --- a/lib/tasks/tokens.rake +++ b/lib/tasks/tokens.rake @@ -24,7 +24,7 @@ namespace :tokens do end end -class TmpUser < ActiveRecord::Base +class TmpUser < ApplicationRecord include TokenAuthenticatable self.table_name = 'users' diff --git a/spec/features/admin/dashboard_spec.rb b/spec/features/admin/dashboard_spec.rb index a6ca0803469..9ba007d0b12 100644 --- a/spec/features/admin/dashboard_spec.rb +++ b/spec/features/admin/dashboard_spec.rb @@ -16,8 +16,8 @@ describe 'admin visits dashboard' do # Make sure the fork_networks & fork_networks reltuples have been updated # to get a correct count on postgresql if Gitlab::Database.postgresql? - ActiveRecord::Base.connection.execute('ANALYZE fork_networks') - ActiveRecord::Base.connection.execute('ANALYZE fork_network_members') + ApplicationRecord.connection.execute('ANALYZE fork_networks') + ApplicationRecord.connection.execute('ANALYZE fork_network_members') end visit admin_root_path diff --git a/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb b/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb index 5432d270555..f20148d57a2 100644 --- a/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb +++ b/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb @@ -216,7 +216,7 @@ end # describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migration, schema: 20170825154015 do let(:user_class) do - Class.new(ActiveRecord::Base) do + Class.new(ApplicationRecord) do self.table_name = 'users' end end diff --git a/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb b/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb index 0dee683350f..094ef634285 100644 --- a/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb +++ b/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb @@ -114,7 +114,7 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :sidekiq, :migra it 'does not drop the temporary tracking table after processing the batch, if there are still untracked rows' do subject.perform(1, untracked_files_for_uploads.last.id - 1) - expect(ActiveRecord::Base.connection.data_source_exists?(:untracked_files_for_uploads)).to be_truthy + expect(ApplicationRecord.connection.data_source_exists?(:untracked_files_for_uploads)).to be_truthy end it 'drops the temporary tracking table after processing the batch, if there are no untracked rows left' do diff --git a/spec/lib/gitlab/current_settings_spec.rb b/spec/lib/gitlab/current_settings_spec.rb index 55490f37ac7..fce505a286f 100644 --- a/spec/lib/gitlab/current_settings_spec.rb +++ b/spec/lib/gitlab/current_settings_spec.rb @@ -50,7 +50,7 @@ describe Gitlab::CurrentSettings do before do # For some reason, `allow(described_class).to receive(:connect_to_db?).and_return(false)` causes issues # during the initialization phase of the test suite, so instead let's mock the internals of it - allow(ActiveRecord::Base.connection).to receive(:active?).and_return(false) + allow(ApplicationRecord.connection).to receive(:active?).and_return(false) expect(ApplicationSetting).not_to receive(:current) end @@ -78,8 +78,8 @@ describe Gitlab::CurrentSettings do it 'fetches the settings from cache' do # For some reason, `allow(described_class).to receive(:connect_to_db?).and_return(true)` causes issues # during the initialization phase of the test suite, so instead let's mock the internals of it - expect(ActiveRecord::Base.connection).not_to receive(:active?) - expect(ActiveRecord::Base.connection).not_to receive(:cached_table_exists?) + expect(ApplicationRecord.connection).not_to receive(:active?) + expect(ApplicationRecord.connection).not_to receive(:cached_table_exists?) expect(ActiveRecord::Migrator).not_to receive(:needs_migration?) expect(ActiveRecord::QueryRecorder.new { described_class.current_application_settings }.count).to eq(0) end @@ -87,8 +87,8 @@ describe Gitlab::CurrentSettings do context 'and no settings in cache' do before do - allow(ActiveRecord::Base.connection).to receive(:active?).and_return(true) - allow(ActiveRecord::Base.connection).to receive(:cached_table_exists?).with('application_settings').and_return(true) + allow(ApplicationRecord.connection).to receive(:active?).and_return(true) + allow(ApplicationRecord.connection).to receive(:cached_table_exists?).with('application_settings').and_return(true) end it 'creates default ApplicationSettings if none are present' do diff --git a/spec/lib/gitlab/database/count_spec.rb b/spec/lib/gitlab/database/count_spec.rb index 407d9470785..a71cdec8026 100644 --- a/spec/lib/gitlab/database/count_spec.rb +++ b/spec/lib/gitlab/database/count_spec.rb @@ -55,8 +55,8 @@ describe Gitlab::Database::Count do describe 'when all reltuples have been updated' do before do - ActiveRecord::Base.connection.execute('ANALYZE projects') - ActiveRecord::Base.connection.execute('ANALYZE identities') + ApplicationRecord.connection.execute('ANALYZE projects') + ApplicationRecord.connection.execute('ANALYZE identities') end it 'counts models with the standard way' do diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb index 23f27939dd2..1c3c010f317 100644 --- a/spec/lib/gitlab/database/migration_helpers_spec.rb +++ b/spec/lib/gitlab/database/migration_helpers_spec.rb @@ -1197,7 +1197,7 @@ describe Gitlab::Database::MigrationHelpers do let!(:issue) { create(:issue, :closed, closed_at: Time.zone.now) } let(:issue_model) do - Class.new(ActiveRecord::Base) do + Class.new(ApplicationRecord) do self.table_name = 'issues' include EachBatch end @@ -1355,7 +1355,7 @@ describe Gitlab::Database::MigrationHelpers do context 'when an index with a function exists', :postgresql do before do - ActiveRecord::Base.connection.execute( + ApplicationRecord.connection.execute( 'CREATE INDEX test_index ON projects (LOWER(path));' ) end diff --git a/spec/lib/gitlab/database/multi_threaded_migration_spec.rb b/spec/lib/gitlab/database/multi_threaded_migration_spec.rb index 6c45f13bb5a..1f8f00c9025 100644 --- a/spec/lib/gitlab/database/multi_threaded_migration_spec.rb +++ b/spec/lib/gitlab/database/multi_threaded_migration_spec.rb @@ -17,7 +17,7 @@ describe Gitlab::Database::MultiThreadedMigration do end it 'returns the global connection if no thread-local connection was set' do - expect(migration.connection).to eq(ActiveRecord::Base.connection) + expect(migration.connection).to eq(ApplicationRecord.connection) end end diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 7d76519dddd..5ba39c0f3b9 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -389,7 +389,7 @@ describe Gitlab::Database do describe '.cached_column_exists?' do it 'only retrieves data once' do - expect(ActiveRecord::Base.connection).to receive(:columns).once.and_call_original + expect(ApplicationRecord.connection).to receive(:columns).once.and_call_original 2.times do expect(described_class.cached_column_exists?(:projects, :id)).to be_truthy @@ -401,11 +401,11 @@ describe Gitlab::Database do describe '.cached_table_exists?' do it 'only retrieves data once per table' do if Gitlab.rails5? - expect(ActiveRecord::Base.connection).to receive(:data_source_exists?).with(:projects).once.and_call_original - expect(ActiveRecord::Base.connection).to receive(:data_source_exists?).with(:bogus_table_name).once.and_call_original + expect(ApplicationRecord.connection).to receive(:data_source_exists?).with(:projects).once.and_call_original + expect(ApplicationRecord.connection).to receive(:data_source_exists?).with(:bogus_table_name).once.and_call_original else - expect(ActiveRecord::Base.connection).to receive(:table_exists?).with(:projects).once.and_call_original - expect(ActiveRecord::Base.connection).to receive(:table_exists?).with(:bogus_table_name).once.and_call_original + expect(ApplicationRecord.connection).to receive(:table_exists?).with(:projects).once.and_call_original + expect(ApplicationRecord.connection).to receive(:table_exists?).with(:bogus_table_name).once.and_call_original end 2.times do @@ -446,18 +446,18 @@ describe Gitlab::Database do describe '.db_read_only?' do context 'when using PostgreSQL' do before do - allow(ActiveRecord::Base.connection).to receive(:execute).and_call_original + allow(ApplicationRecord.connection).to receive(:execute).and_call_original expect(described_class).to receive(:postgresql?).and_return(true) end it 'detects a read only database' do - allow(ActiveRecord::Base.connection).to receive(:execute).with('SELECT pg_is_in_recovery()').and_return([{ "pg_is_in_recovery" => "t" }]) + allow(ApplicationRecord.connection).to receive(:execute).with('SELECT pg_is_in_recovery()').and_return([{ "pg_is_in_recovery" => "t" }]) expect(described_class.db_read_only?).to be_truthy end it 'detects a read write database' do - allow(ActiveRecord::Base.connection).to receive(:execute).with('SELECT pg_is_in_recovery()').and_return([{ "pg_is_in_recovery" => "f" }]) + allow(ApplicationRecord.connection).to receive(:execute).with('SELECT pg_is_in_recovery()').and_return([{ "pg_is_in_recovery" => "f" }]) expect(described_class.db_read_only?).to be_falsey end diff --git a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb index 5dc372263ad..f5aef44f981 100644 --- a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb +++ b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb @@ -202,7 +202,7 @@ describe Gitlab::ImportExport::ProjectTreeSaver do end it 'does not complain about non UTF-8 characters in MR diff files' do - ActiveRecord::Base.connection.execute("UPDATE merge_request_diff_files SET diff = '---\n- :diff: !binary |-\n LS0tIC9kZXYvbnVsbAorKysgYi9pbWFnZXMvbnVjb3IucGRmCkBAIC0wLDAg\n KzEsMTY3OSBAQAorJVBERi0xLjUNJeLjz9MNCisxIDAgb2JqDTw8L01ldGFk\n YXR'") + ApplicationRecord.connection.execute("UPDATE merge_request_diff_files SET diff = '---\n- :diff: !binary |-\n LS0tIC9kZXYvbnVsbAorKysgYi9pbWFnZXMvbnVjb3IucGRmCkBAIC0wLDAg\n KzEsMTY3OSBAQAorJVBERi0xLjUNJeLjz9MNCisxIDAgb2JqDTw8L01ldGFk\n YXR'") expect(project_tree_saver.save).to be true end diff --git a/spec/lib/gitlab/profiler_spec.rb b/spec/lib/gitlab/profiler_spec.rb index 4059188fba1..2c2b5da745a 100644 --- a/spec/lib/gitlab/profiler_spec.rb +++ b/spec/lib/gitlab/profiler_spec.rb @@ -185,8 +185,8 @@ describe Gitlab::Profiler do it 'uses the replacement logger for the duration of the block' do expect(null_logger).to receive(:debug).and_call_original - expect { described_class.with_custom_logger(null_logger) { ActiveRecord::Base.logger.debug('foo') } } - .to not_change { ActiveRecord::Base.logger } + expect { described_class.with_custom_logger(null_logger) { ApplicationRecord.logger.debug('foo') } } + .to not_change { ApplicationRecord.logger } .and not_change { ActionController::Base.logger } .and not_change { ActiveSupport::LogSubscriber.colorize_logging } end @@ -203,7 +203,7 @@ describe Gitlab::Profiler do it 'does not modify the standard Rails loggers' do expect { described_class.with_custom_logger(nil) { } } - .to not_change { ActiveRecord::Base.logger } + .to not_change { ApplicationRecord.logger } .and not_change { ActionController::Base.logger } .and not_change { ActiveSupport::LogSubscriber.colorize_logging } end diff --git a/spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb b/spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb index f8faeffb935..1c6ee1939e1 100644 --- a/spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb +++ b/spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb @@ -20,7 +20,7 @@ describe Gitlab::QueryLimiting::ActiveSupportSubscriber do context 'when the query is actually a rails cache hit' do it 'does not increment the number of executed SQL queries' do - ActiveRecord::Base.connection.cache do + ApplicationRecord.connection.cache do User.count User.count end diff --git a/spec/lib/gitlab/sql/cte_spec.rb b/spec/lib/gitlab/sql/cte_spec.rb index d6763c7b2e1..11e436655a6 100644 --- a/spec/lib/gitlab/sql/cte_spec.rb +++ b/spec/lib/gitlab/sql/cte_spec.rb @@ -6,9 +6,9 @@ describe Gitlab::SQL::CTE, :postgresql do relation = User.where(id: 1) cte = described_class.new(:cte_name, relation) sql = cte.to_arel.to_sql - name = ActiveRecord::Base.connection.quote_table_name(:cte_name) + name = ApplicationRecord.connection.quote_table_name(:cte_name) - sql1 = ActiveRecord::Base.connection.unprepared_statement do + sql1 = ApplicationRecord.connection.unprepared_statement do relation.except(:order).to_sql end @@ -21,8 +21,8 @@ describe Gitlab::SQL::CTE, :postgresql do cte = described_class.new(:cte_name, nil) table = Arel::Table.new(:kittens) - source_name = ActiveRecord::Base.connection.quote_table_name(:cte_name) - alias_name = ActiveRecord::Base.connection.quote_table_name(:kittens) + source_name = ApplicationRecord.connection.quote_table_name(:cte_name) + alias_name = ApplicationRecord.connection.quote_table_name(:kittens) expect(cte.alias_to(table).to_sql).to eq("#{source_name} AS #{alias_name}") end diff --git a/spec/lib/gitlab/sql/glob_spec.rb b/spec/lib/gitlab/sql/glob_spec.rb index 1cf8935bfe3..04575308bb0 100644 --- a/spec/lib/gitlab/sql/glob_spec.rb +++ b/spec/lib/gitlab/sql/glob_spec.rb @@ -45,10 +45,10 @@ describe Gitlab::SQL::Glob do end def query(sql) - ActiveRecord::Base.connection.select_all(sql) + ApplicationRecord.connection.select_all(sql) end def quote(string) - ActiveRecord::Base.connection.quote(string) + ApplicationRecord.connection.quote(string) end end diff --git a/spec/lib/gitlab/sql/recursive_cte_spec.rb b/spec/lib/gitlab/sql/recursive_cte_spec.rb index 25146860615..4337084005b 100644 --- a/spec/lib/gitlab/sql/recursive_cte_spec.rb +++ b/spec/lib/gitlab/sql/recursive_cte_spec.rb @@ -12,9 +12,9 @@ describe Gitlab::SQL::RecursiveCTE, :postgresql do cte << rel2 sql = cte.to_arel.to_sql - name = ActiveRecord::Base.connection.quote_table_name(:cte_name) + name = ApplicationRecord.connection.quote_table_name(:cte_name) - sql1, sql2 = ActiveRecord::Base.connection.unprepared_statement do + sql1, sql2 = ApplicationRecord.connection.unprepared_statement do [rel1.except(:order).to_sql, rel2.except(:order).to_sql] end @@ -26,8 +26,8 @@ describe Gitlab::SQL::RecursiveCTE, :postgresql do it 'returns an alias for the CTE' do table = Arel::Table.new(:kittens) - source_name = ActiveRecord::Base.connection.quote_table_name(:cte_name) - alias_name = ActiveRecord::Base.connection.quote_table_name(:kittens) + source_name = ApplicationRecord.connection.quote_table_name(:cte_name) + alias_name = ApplicationRecord.connection.quote_table_name(:kittens) expect(cte.alias_to(table).to_sql).to eq("#{source_name} AS #{alias_name}") end diff --git a/spec/migrations/create_missing_namespace_for_internal_users_spec.rb b/spec/migrations/create_missing_namespace_for_internal_users_spec.rb index ac3a4b1f68f..3f7ad9a90e3 100644 --- a/spec/migrations/create_missing_namespace_for_internal_users_spec.rb +++ b/spec/migrations/create_missing_namespace_for_internal_users_spec.rb @@ -7,7 +7,7 @@ describe CreateMissingNamespaceForInternalUsers, :migration do let(:routes) { table(:routes) } internal_user_types = [:ghost] - internal_user_types << :support_bot if ActiveRecord::Base.connection.column_exists?(:users, :support_bot) + internal_user_types << :support_bot if ApplicationRecord.connection.column_exists?(:users, :support_bot) internal_user_types.each do |attr| context "for #{attr} user" do diff --git a/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb b/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb index ba4c66057d4..de057954d26 100644 --- a/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb +++ b/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb @@ -9,7 +9,7 @@ describe MigrateGcpClustersToNewClustersArchitectures, :migration do let(:service) { GcpMigrationSpec::KubernetesService.create!(project_id: project.id) } module GcpMigrationSpec - class KubernetesService < ActiveRecord::Base + class KubernetesService < ApplicationRecord self.table_name = 'services' serialize :properties, JSON @@ -53,7 +53,7 @@ describe MigrateGcpClustersToNewClustersArchitectures, :migration do let(:cluster_id) { cluster.id } before do - ActiveRecord::Base.connection.execute <<-SQL + ApplicationRecord.connection.execute <<-SQL INSERT INTO gcp_clusters (project_id, user_id, service_id, status, gcp_cluster_size, created_at, updated_at, enabled, status_reason, project_namespace, endpoint, ca_cert, encrypted_kubernetes_token, encrypted_kubernetes_token_iv, username, encrypted_password, encrypted_password_iv, gcp_project_id, gcp_cluster_zone, gcp_cluster_name, gcp_machine_type, gcp_operation_id, encrypted_gcp_token, encrypted_gcp_token_iv) VALUES (#{project_id}, #{user_id}, #{service_id}, #{status}, #{gcp_cluster_size}, #{created_at}, #{updated_at}, #{enabled}, #{status_reason}, #{project_namespace}, #{endpoint}, #{ca_cert}, #{encrypted_kubernetes_token}, #{encrypted_kubernetes_token_iv}, #{username}, #{encrypted_password}, #{encrypted_password_iv}, #{gcp_project_id}, #{gcp_cluster_zone}, #{gcp_cluster_name}, #{gcp_machine_type}, #{gcp_operation_id}, #{encrypted_gcp_token}, #{encrypted_gcp_token_iv}); SQL @@ -129,7 +129,7 @@ describe MigrateGcpClustersToNewClustersArchitectures, :migration do let(:cluster_id) { cluster.id } before do - ActiveRecord::Base.connection.execute <<-SQL + ApplicationRecord.connection.execute <<-SQL INSERT INTO gcp_clusters (project_id, user_id, service_id, status, gcp_cluster_size, created_at, updated_at, enabled, status_reason, project_namespace, endpoint, ca_cert, encrypted_kubernetes_token, encrypted_kubernetes_token_iv, username, encrypted_password, encrypted_password_iv, gcp_project_id, gcp_cluster_zone, gcp_cluster_name, gcp_machine_type, gcp_operation_id, encrypted_gcp_token, encrypted_gcp_token_iv) VALUES (#{project_id}, #{user_id}, #{service_id}, #{status}, #{gcp_cluster_size}, #{created_at}, #{updated_at}, #{enabled}, #{status_reason}, #{project_namespace}, #{endpoint}, #{ca_cert}, #{encrypted_kubernetes_token}, #{encrypted_kubernetes_token_iv}, #{username}, #{encrypted_password}, #{encrypted_password_iv}, #{gcp_project_id}, #{gcp_cluster_zone}, #{gcp_cluster_name}, #{gcp_machine_type}, #{gcp_operation_id}, #{encrypted_gcp_token}, #{encrypted_gcp_token_iv}); SQL diff --git a/spec/models/concerns/batch_destroy_dependent_associations_spec.rb b/spec/models/concerns/batch_destroy_dependent_associations_spec.rb index e5392fe0462..4e0bd8609c1 100644 --- a/spec/models/concerns/batch_destroy_dependent_associations_spec.rb +++ b/spec/models/concerns/batch_destroy_dependent_associations_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe BatchDestroyDependentAssociations do - class TestProject < ActiveRecord::Base + class TestProject < ApplicationRecord self.table_name = 'projects' has_many :builds, dependent: :destroy diff --git a/spec/models/concerns/case_sensitivity_spec.rb b/spec/models/concerns/case_sensitivity_spec.rb index 1bf6c9b3404..3ccc6602b73 100644 --- a/spec/models/concerns/case_sensitivity_spec.rb +++ b/spec/models/concerns/case_sensitivity_spec.rb @@ -2,9 +2,9 @@ require 'spec_helper' describe CaseSensitivity do describe '.iwhere' do - let(:connection) { ActiveRecord::Base.connection } + let(:connection) { ApplicationRecord.connection } let(:model) do - Class.new(ActiveRecord::Base) do + Class.new(ApplicationRecord) do include CaseSensitivity self.table_name = 'namespaces' end diff --git a/spec/models/concerns/each_batch_spec.rb b/spec/models/concerns/each_batch_spec.rb index 17224c09693..154cfbadb1c 100644 --- a/spec/models/concerns/each_batch_spec.rb +++ b/spec/models/concerns/each_batch_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe EachBatch do describe '.each_batch' do let(:model) do - Class.new(ActiveRecord::Base) do + Class.new(ApplicationRecord) do include EachBatch self.table_name = 'users' diff --git a/spec/models/concerns/from_union_spec.rb b/spec/models/concerns/from_union_spec.rb index ee427a667c6..9bffaa6d114 100644 --- a/spec/models/concerns/from_union_spec.rb +++ b/spec/models/concerns/from_union_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe FromUnion do describe '.from_union' do let(:model) do - Class.new(ActiveRecord::Base) do + Class.new(ApplicationRecord) do self.table_name = 'users' include FromUnion diff --git a/spec/models/concerns/optionally_search_spec.rb b/spec/models/concerns/optionally_search_spec.rb index ff4212ddf18..f42343e9d6a 100644 --- a/spec/models/concerns/optionally_search_spec.rb +++ b/spec/models/concerns/optionally_search_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' describe OptionallySearch do let(:model) do - Class.new(ActiveRecord::Base) do + Class.new(ApplicationRecord) do self.table_name = 'users' include OptionallySearch diff --git a/spec/models/concerns/sortable_spec.rb b/spec/models/concerns/sortable_spec.rb index 39c16ae60af..1b4ebdb7d79 100644 --- a/spec/models/concerns/sortable_spec.rb +++ b/spec/models/concerns/sortable_spec.rb @@ -42,8 +42,8 @@ describe Sortable do it 'ascending' do expect(relation).to receive(:reorder).once.and_call_original - table = Regexp.escape(ActiveRecord::Base.connection.quote_table_name(:namespaces)) - column = Regexp.escape(ActiveRecord::Base.connection.quote_column_name(:name)) + table = Regexp.escape(ApplicationRecord.connection.quote_table_name(:namespaces)) + column = Regexp.escape(ApplicationRecord.connection.quote_column_name(:name)) sql = relation.order_by('name_asc').to_sql @@ -53,8 +53,8 @@ describe Sortable do it 'descending' do expect(relation).to receive(:reorder).once.and_call_original - table = Regexp.escape(ActiveRecord::Base.connection.quote_table_name(:namespaces)) - column = Regexp.escape(ActiveRecord::Base.connection.quote_column_name(:name)) + table = Regexp.escape(ApplicationRecord.connection.quote_table_name(:namespaces)) + column = Regexp.escape(ApplicationRecord.connection.quote_column_name(:name)) sql = relation.order_by('name_desc').to_sql diff --git a/spec/support/helpers/database_connection_helpers.rb b/spec/support/helpers/database_connection_helpers.rb index 763329499f0..7b8d0b5cb9e 100644 --- a/spec/support/helpers/database_connection_helpers.rb +++ b/spec/support/helpers/database_connection_helpers.rb @@ -1,6 +1,6 @@ module DatabaseConnectionHelpers def run_with_new_database_connection - pool = ActiveRecord::Base.connection_pool + pool = ApplicationRecord.connection_pool conn = pool.checkout yield conn ensure diff --git a/spec/support/helpers/migrations_helpers.rb b/spec/support/helpers/migrations_helpers.rb index 5887c3eab74..c3a25569b45 100644 --- a/spec/support/helpers/migrations_helpers.rb +++ b/spec/support/helpers/migrations_helpers.rb @@ -1,6 +1,6 @@ module MigrationsHelpers def active_record_base - ActiveRecord::Base + ApplicationRecord end def table(name) @@ -29,7 +29,7 @@ module MigrationsHelpers end def foreign_key_exists?(source, target = nil, column: nil) - ActiveRecord::Base.connection.foreign_keys(source).any? do |key| + ApplicationRecord.connection.foreign_keys(source).any? do |key| if column key.options[:column].to_s == column.to_s else diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb index 8c4360d4cf0..a7b8aa437da 100644 --- a/spec/tasks/gitlab/backup_rake_spec.rb +++ b/spec/tasks/gitlab/backup_rake_spec.rb @@ -113,7 +113,7 @@ describe 'gitlab:app namespace rake task' do describe 'backup' do before do # This reconnect makes our project fixture disappear, breaking the restore. Stub it out. - allow(ActiveRecord::Base.connection).to receive(:reconnect!) + allow(ApplicationRecord.connection).to receive(:reconnect!) end describe 'backup creation and deletion using custom_hooks' do diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb index 5818892d56a..8aa66a28df5 100644 --- a/spec/tasks/gitlab/db_rake_spec.rb +++ b/spec/tasks/gitlab/db_rake_spec.rb @@ -20,7 +20,7 @@ describe 'gitlab:db namespace rake task' do describe 'configure' do it 'invokes db:migrate when schema has already been loaded' do - allow(ActiveRecord::Base.connection).to receive(:tables).and_return(%w[table1 table2]) + allow(ApplicationRecord.connection).to receive(:tables).and_return(%w[table1 table2]) expect(Rake::Task['db:migrate']).to receive(:invoke) expect(Rake::Task['db:schema:load']).not_to receive(:invoke) expect(Rake::Task['db:seed_fu']).not_to receive(:invoke) @@ -28,7 +28,7 @@ describe 'gitlab:db namespace rake task' do end it 'invokes db:shema:load and db:seed_fu when schema is not loaded' do - allow(ActiveRecord::Base.connection).to receive(:tables).and_return([]) + allow(ApplicationRecord.connection).to receive(:tables).and_return([]) expect(Rake::Task['db:schema:load']).to receive(:invoke) expect(Rake::Task['db:seed_fu']).to receive(:invoke) expect(Rake::Task['db:migrate']).not_to receive(:invoke) @@ -36,7 +36,7 @@ describe 'gitlab:db namespace rake task' do end it 'invokes db:shema:load and db:seed_fu when there is only a single table present' do - allow(ActiveRecord::Base.connection).to receive(:tables).and_return(['default']) + allow(ApplicationRecord.connection).to receive(:tables).and_return(['default']) expect(Rake::Task['db:schema:load']).to receive(:invoke) expect(Rake::Task['db:seed_fu']).to receive(:invoke) expect(Rake::Task['db:migrate']).not_to receive(:invoke) @@ -44,17 +44,17 @@ describe 'gitlab:db namespace rake task' do end it 'does not invoke any other rake tasks during an error' do - allow(ActiveRecord::Base).to receive(:connection).and_raise(RuntimeError, 'error') + allow(ApplicationRecord).to receive(:connection).and_raise(RuntimeError, 'error') expect(Rake::Task['db:migrate']).not_to receive(:invoke) expect(Rake::Task['db:schema:load']).not_to receive(:invoke) expect(Rake::Task['db:seed_fu']).not_to receive(:invoke) expect { run_rake_task('gitlab:db:configure') }.to raise_error(RuntimeError, 'error') # unstub connection so that the database cleaner still works - allow(ActiveRecord::Base).to receive(:connection).and_call_original + allow(ApplicationRecord).to receive(:connection).and_call_original end it 'does not invoke seed after a failed schema_load' do - allow(ActiveRecord::Base.connection).to receive(:tables).and_return([]) + allow(ApplicationRecord.connection).to receive(:tables).and_return([]) allow(Rake::Task['db:schema:load']).to receive(:invoke).and_raise(RuntimeError, 'error') expect(Rake::Task['db:schema:load']).to receive(:invoke) expect(Rake::Task['db:seed_fu']).not_to receive(:invoke) @@ -75,7 +75,7 @@ describe 'gitlab:db namespace rake task' do end it 'adds post deployment migrations before schema load if the schema is not already loaded' do - allow(ActiveRecord::Base.connection).to receive(:tables).and_return([]) + allow(ApplicationRecord.connection).to receive(:tables).and_return([]) expect(Gitlab::Database).to receive(:add_post_migrate_path_to_rails).and_call_original expect(Rake::Task['db:schema:load']).to receive(:invoke) expect(Rake::Task['db:seed_fu']).to receive(:invoke) @@ -85,7 +85,7 @@ describe 'gitlab:db namespace rake task' do end it 'ignores post deployment migrations when schema has already been loaded' do - allow(ActiveRecord::Base.connection).to receive(:tables).and_return(%w[table1 table2]) + allow(ApplicationRecord.connection).to receive(:tables).and_return(%w[table1 table2]) expect(Rake::Task['db:migrate']).to receive(:invoke) expect(Gitlab::Database).not_to receive(:add_post_migrate_path_to_rails) expect(Rake::Task['db:schema:load']).not_to receive(:invoke) |