Database migration and models for instance event type filters
What does this MR do and why?
We have added instance level external audit event destinations as part of issue #335175 (closed). Now we need to add audit event filters for these destinations which will allow users to add filters for the audit events for each external destination, restricting streaming of certain audit event types to a certain destination. These event filters are similar to the event filters for group level external audit event streaming destinations.
This MR does following:
- Adds a migration for creating table
audit_events_streaming_event_type_filters
. - Adds a corresponding model
InstanceEventTypeFilter
for the table. - Since some things are common between
EventTypeFilter
andInstanceEventTypeFilter
, we have added a concernStreamableEventTypeFilter
for having common validations and methods.
Note: GraphQL APIs for performing CRUD operations and changes related to destination model will be added in a subsequent MR.
Migration details:
up
RAILS_ENV=development bin/rails db:migrate:up:main VERSION=20230609115844
main: == [advisory_lock_connection] object_id: 227840, pg_backend_pid: 43679
main: == 20230609115844 CreateAuditEventsStreamingInstanceEventTypeFilters: migrating
main: -- create_table(:audit_events_streaming_instance_event_type_filters)
main: -- quote_column_name(:audit_event_type)
main: -> 0.0000s
main: -> 0.0069s
main: == 20230609115844 CreateAuditEventsStreamingInstanceEventTypeFilters: migrated (0.1260s)
main: == [advisory_lock_connection] object_id: 227840, pg_backend_pid: 43679
down
RAILS_ENV=development bin/rails db:migrate:down:main VERSION=20230609115844
main: == [advisory_lock_connection] object_id: 227900, pg_backend_pid: 43245
main: == 20230609115844 CreateAuditEventsStreamingInstanceEventTypeFilters: reverting
main: -- drop_table(:audit_events_streaming_instance_event_type_filters)
main: -> 0.0068s
main: == 20230609115844 CreateAuditEventsStreamingInstanceEventTypeFilters: reverted (0.0931s)
Queries
audit_event_type_in
Query for scope SELECT
"audit_events_streaming_instance_event_type_filters".*
FROM
"audit_events_streaming_instance_event_type_filters"
WHERE
"audit_events_streaming_instance_event_type_filters"."audit_event_type" = 'audit-event-type-1'
How to set up and validate locally
Since there are no functional changes in this MR, there is nothing to validate apart from running the migration and checking the model in the rails console. There will be subsequent MRs related to APIs around the new table/model added.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #411524 (closed)