Commit b6bbaee5 authored by Yannis Roussos's avatar Yannis Roussos

Merge branch 'add-domain-type-to-alerts' into 'master'

Add domain column to alerts table

See merge request gitlab-org/gitlab!49120
parents b0f9827d e7354c57
......@@ -69,6 +69,11 @@ module AlertManagement
unknown: 5
}
enum domain: {
operations: 0,
threat_monitoring: 1
}
state_machine :status, initial: :triggered do
state :triggered, value: STATUSES[:triggered]
......
---
title: Add domain column to alerts table
merge_request: 49120
author:
type: added
# frozen_string_literal: true
class AddDomainEnumToAlerts < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
with_lock_retries do
add_column :alert_management_alerts, :domain, :integer, limit: 2, default: 0
end
end
def down
with_lock_retries do
remove_column :alert_management_alerts, :domain, :integer, limit: 2
end
end
end
# frozen_string_literal: true
class AddIndexToDomain < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_alert_management_alerts_on_domain'
disable_ddl_transaction!
def up
add_concurrent_index :alert_management_alerts, :domain, name: INDEX_NAME
end
def down
remove_concurrent_index :alert_management_alerts, :domain, name: INDEX_NAME
end
end
4bb54293c339e20082a739f7724b02141d8fb3b0b140e21ac2acab6cbd2d2f01
\ No newline at end of file
3b6d3fb9c279f5e8c76921e654b188a5a5ba0fddd7ff753a03706b41f43240ed
\ No newline at end of file
......@@ -8811,6 +8811,7 @@ CREATE TABLE alert_management_alerts (
payload jsonb DEFAULT '{}'::jsonb NOT NULL,
prometheus_alert_id integer,
environment_id integer,
domain smallint DEFAULT 0,
CONSTRAINT check_2df3e2fdc1 CHECK ((char_length(monitoring_tool) <= 100)),
CONSTRAINT check_5e9e57cadb CHECK ((char_length(description) <= 1000)),
CONSTRAINT check_bac14dddde CHECK ((char_length(service) <= 100)),
......@@ -20435,6 +20436,8 @@ CREATE INDEX index_alert_assignees_on_alert_id ON alert_management_alert_assigne
CREATE UNIQUE INDEX index_alert_assignees_on_user_id_and_alert_id ON alert_management_alert_assignees USING btree (user_id, alert_id);
CREATE INDEX index_alert_management_alerts_on_domain ON alert_management_alerts USING btree (domain);
CREATE INDEX index_alert_management_alerts_on_environment_id ON alert_management_alerts USING btree (environment_id) WHERE (environment_id IS NOT NULL);
CREATE INDEX index_alert_management_alerts_on_issue_id ON alert_management_alerts USING btree (issue_id);
......
......@@ -54,7 +54,6 @@ RSpec.describe Projects::Alerting::NotifyService do
shared_examples 'assigns the alert properties' do
it 'ensure that created alert has all data properly assigned' do
subject
expect(last_alert_attributes).to match(
project_id: project.id,
title: payload_raw.fetch(:title),
......@@ -62,6 +61,7 @@ RSpec.describe Projects::Alerting::NotifyService do
severity: payload_raw.fetch(:severity),
status: AlertManagement::Alert.status_value(:triggered),
events: 1,
domain: 'operations',
hosts: payload_raw.fetch(:hosts),
payload: payload_raw.with_indifferent_access,
issue_id: nil,
......@@ -187,6 +187,7 @@ RSpec.describe Projects::Alerting::NotifyService do
status: AlertManagement::Alert.status_value(:triggered),
events: 1,
hosts: [],
domain: 'operations',
payload: payload_raw.with_indifferent_access,
issue_id: nil,
description: nil,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment