Skip to content

Adding active column to custom http audit event destination headers

Hitesh Raghuvanshi requested to merge 367509-activate-header-migration into master

What does this MR do and why?

  1. Adding a non null boolean column named active with default value as true to streaming headers tables for external audit event destinations. This column will be used for enabling and disabling the streaming headers.
  2. Queries on this column will be made to fetch all the headers with value true for a destination.
  3. Not adding an index on this column as there is a limit of 20 headers per external audit event destination, so I don't think that index is required here.

Database

As of 8th August 2023 10:13 GMT, there are total 145 rows in audit_events_streaming_headers table and 0 rows in instance_audit_events_streaming_headers table.

image

Migrations data


# up for audit_events_streaming_headers

RAILS_ENV=development bin/rails db:migrate:up:main VERSION=20230807101745
main: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 20490
main: == 20230807101745 AddActiveToAuditEventsStreamingHeaders: migrating ===========
main: -- add_column(:audit_events_streaming_headers, :active, :boolean, {:default=>true, :null=>false})
main:    -> 0.0022s
main: == 20230807101745 AddActiveToAuditEventsStreamingHeaders: migrated (0.0058s) ==

main: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 20490

# down for audit_events_streaming_headers

RAILS_ENV=development bin/rails db:migrate:down:main VERSION=20230807101745
main: == [advisory_lock_connection] object_id: 224620, pg_backend_pid: 20019
main: == 20230807101745 AddActiveToAuditEventsStreamingHeaders: reverting ===========
main: -- remove_column(:audit_events_streaming_headers, :active, :boolean, {:default=>true, :null=>false})
main:    -> 0.0019s
main: == 20230807101745 AddActiveToAuditEventsStreamingHeaders: reverted (0.0078s) ==

main: == [advisory_lock_connection] object_id: 224620, pg_backend_pid: 20019


===================================================================================================================

# up for instance_audit_events_streaming_headers

RAILS_ENV=development bin/rails db:migrate:up:main VERSION=20230807105131
main: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 19576
main: == 20230807105131 AddActiveToInstanceAuditEventsStreamingHeaders: migrating ===
main: -- add_column(:instance_audit_events_streaming_headers, :active, :boolean, {:default=>true, :null=>false})
main:    -> 0.0047s
main: == 20230807105131 AddActiveToInstanceAuditEventsStreamingHeaders: migrated (0.0085s)

main: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 19576

# down for instance_audit_events_streaming_headers

RAILS_ENV=development bin/rails db:migrate:down:main VERSION=20230807105131
main: == [advisory_lock_connection] object_id: 224640, pg_backend_pid: 19107
main: == 20230807105131 AddActiveToInstanceAuditEventsStreamingHeaders: reverting ===
main: -- remove_column(:instance_audit_events_streaming_headers, :active, :boolean, {:default=>true, :null=>false})
main:    -> 0.0051s
main: == 20230807105131 AddActiveToInstanceAuditEventsStreamingHeaders: reverted (0.0107s)

main: == [advisory_lock_connection] object_id: 224640, pg_backend_pid: 19107

How to set up and validate locally

  1. Run the migrations.
  2. Open psql by running gdk psql.
  3. Run \d instance_audit_events_streaming_headers;, output would be something like following, notice active column details: image
  4. Run \d audit_events_streaming_headers;, output would be as follows, again notice active column details: image

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #367509 (closed)

Edited by Hitesh Raghuvanshi

Merge request reports