Commit 01d1d439 authored by Sashi's avatar Sashi

Add rule_index to security_orchestration_policy_rule_schedules

This change introduces a new column rule_index
to security_orchestration_policy_rule_schedules table to keep
track of the  values from the security policy file.

Changelog: added
parent f74b0c27
# 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 (
user_id bigint NOT NULL,
policy_index integer NOT NULL,
cron text NOT NULL,
rule_index integer DEFAULT 0 NOT NULL,
CONSTRAINT check_915825a76e CHECK ((char_length(cron) <= 255))
);
......@@ -15,6 +15,7 @@ module Security
validates :security_orchestration_policy_configuration, presence: true
validates :cron, presence: true
validates :policy_index, presence: true
validates :rule_index, presence: true
scope :runnable_schedules, -> { where("next_run_at < ?", Time.zone.now) }
scope :with_owner, -> { includes(:owner) }
......
......@@ -6,6 +6,7 @@ FactoryBot.define do
security_orchestration_policy_configuration
policy_index { 0 }
rule_index { 0 }
cron { '*/10 * * * *' }
end
end
......@@ -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(:cron) }
it { is_expected.to validate_presence_of(:policy_index) }
it { is_expected.to validate_presence_of(:rule_index) }
end
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