Class: Gitlab::BackgroundMigration::FixProjectsWithoutPrometheusService::Migratable::PrometheusService

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/gitlab/background_migration/fix_projects_without_prometheus_service.rb

Overview

Migration model namespace isolated from application code.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.templateObject



71
72
73
# File 'lib/gitlab/background_migration/fix_projects_without_prometheus_service.rb', line 71

def self.template
  find_by(template: true)
end

.typeObject



67
68
69
# File 'lib/gitlab/background_migration/fix_projects_without_prometheus_service.rb', line 67

def self.type
  'PrometheusService'
end

.valuesObject



75
76
77
# File 'lib/gitlab/background_migration/fix_projects_without_prometheus_service.rb', line 75

def self.values
  (template&.attributes_for_insert || DEFAULTS).merge('template' => false, 'active' => true).values
end

Instance Method Details

#attributes_for_insertObject



79
80
81
82
83
# File 'lib/gitlab/background_migration/fix_projects_without_prometheus_service.rb', line 79

def attributes_for_insert
  slice(DEFAULTS.keys).transform_values do |v|
    v.is_a?(String) ? "'#{v}'" : v
  end
end