diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-21 18:06:29 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-21 18:06:29 +0000 |
commit | f1bb2a307e9b125a8ee0be3728cb0d1baa21a3d4 (patch) | |
tree | 154817af5e3f1b134be08ef22d1926edf87ab74f /db | |
parent | ad1e4b8fb8104b642fa79ed34fd144bc2bed8a19 (diff) | |
download | gitlab-ce-f1bb2a307e9b125a8ee0be3728cb0d1baa21a3d4.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20190809072552_set_self_monitoring_project_alerting_token.rb | 68 |
1 files changed, 7 insertions, 61 deletions
diff --git a/db/post_migrate/20190809072552_set_self_monitoring_project_alerting_token.rb b/db/post_migrate/20190809072552_set_self_monitoring_project_alerting_token.rb index 0c4faebc548..d10887fb5d5 100644 --- a/db/post_migrate/20190809072552_set_self_monitoring_project_alerting_token.rb +++ b/db/post_migrate/20190809072552_set_self_monitoring_project_alerting_token.rb @@ -3,71 +3,17 @@ class SetSelfMonitoringProjectAlertingToken < ActiveRecord::Migration[5.2] DOWNTIME = false - module Migratable - module Alerting - class ProjectAlertingSetting < ApplicationRecord - self.table_name = 'project_alerting_settings' - - belongs_to :project - - validates :token, presence: true - - attr_encrypted :token, - mode: :per_attribute_iv, - key: Settings.attr_encrypted_db_key_base_truncated, - algorithm: 'aes-256-gcm' - - before_validation :ensure_token - - private - - def ensure_token - self.token ||= generate_token - end - - def generate_token - SecureRandom.hex - end - end - end - - class Project < ApplicationRecord - has_one :alerting_setting, inverse_of: :project, class_name: 'Alerting::ProjectAlertingSetting' - end - - class ApplicationSetting < ApplicationRecord - self.table_name = 'application_settings' - - belongs_to :instance_administration_project, class_name: 'Project' - - def self.current_without_cache - last - end - end - end - - def setup_alertmanager_token(project) - return unless License.feature_available?(:prometheus_alerts) - - project.create_alerting_setting! - end - def up - Gitlab.ee do - project = Migratable::ApplicationSetting.current_without_cache&.instance_administration_project + # no-op + # Converted to no-op in https://gitlab.com/gitlab-org/gitlab/merge_requests/17049. - if project - setup_alertmanager_token(project) - end - end + # This migration has been made a no-op because the pre-requisite migration + # which creates the self-monitoring project has already been removed in + # https://gitlab.com/gitlab-org/gitlab/merge_requests/16864. As + # such, this migration would do nothing. end def down - Gitlab.ee do - Migratable::ApplicationSetting.current_without_cache - &.instance_administration_project - &.alerting_setting - &.destroy! - end + # no-op end end |