Commit 55bb794f authored by Kerri Miller's avatar Kerri Miller

Merge branch 'sk/337537-add-rule-index' into 'master'

Add rule_index to security_orchestration_policy_rule_schedules

See merge request gitlab-org/gitlab!67586
parents d982b664 01d1d439
# frozen_string_literal: true
class AddRuleIndexToSecurityOrchestrationPolicyRuleSchedules < ActiveRecord::Migration[6.1]
def change
add_column :security_orchestration_policy_rule_schedules, :rule_index, :integer, null: false, default: 0
end
end
ec968f1f9fcc5a3551664e74726e1c65b327128e2388e1357ae6d0cf6f05fb95
\ No newline at end of file
...@@ -18053,6 +18053,7 @@ CREATE TABLE security_orchestration_policy_rule_schedules ( ...@@ -18053,6 +18053,7 @@ CREATE TABLE security_orchestration_policy_rule_schedules (
user_id bigint NOT NULL, user_id bigint NOT NULL,
policy_index integer NOT NULL, policy_index integer NOT NULL,
cron text NOT NULL, cron text NOT NULL,
rule_index integer DEFAULT 0 NOT NULL,
CONSTRAINT check_915825a76e CHECK ((char_length(cron) <= 255)) CONSTRAINT check_915825a76e CHECK ((char_length(cron) <= 255))
); );
...@@ -15,6 +15,7 @@ module Security ...@@ -15,6 +15,7 @@ module Security
validates :security_orchestration_policy_configuration, presence: true validates :security_orchestration_policy_configuration, presence: true
validates :cron, presence: true validates :cron, presence: true
validates :policy_index, presence: true validates :policy_index, presence: true
validates :rule_index, presence: true
scope :runnable_schedules, -> { where("next_run_at < ?", Time.zone.now) } scope :runnable_schedules, -> { where("next_run_at < ?", Time.zone.now) }
scope :with_owner, -> { includes(:owner) } scope :with_owner, -> { includes(:owner) }
......
...@@ -6,6 +6,7 @@ FactoryBot.define do ...@@ -6,6 +6,7 @@ FactoryBot.define do
security_orchestration_policy_configuration security_orchestration_policy_configuration
policy_index { 0 } policy_index { 0 }
rule_index { 0 }
cron { '*/10 * * * *' } cron { '*/10 * * * *' }
end end
end end
...@@ -15,6 +15,7 @@ RSpec.describe Security::OrchestrationPolicyRuleSchedule do ...@@ -15,6 +15,7 @@ RSpec.describe Security::OrchestrationPolicyRuleSchedule do
it { is_expected.to validate_presence_of(:security_orchestration_policy_configuration) } it { is_expected.to validate_presence_of(:security_orchestration_policy_configuration) }
it { is_expected.to validate_presence_of(:cron) } it { is_expected.to validate_presence_of(:cron) }
it { is_expected.to validate_presence_of(:policy_index) } it { is_expected.to validate_presence_of(:policy_index) }
it { is_expected.to validate_presence_of(:rule_index) }
end end
describe '.runnable_schedules' do describe '.runnable_schedules' do
......
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