Remove legacy AuditEvent model and all application code referencing it

What does this MR do and why?

Removes the legacy AuditEvent model (app/models/audit_event.rb) and all application code that references it, as part of #615798 (closed).

The AuditEvent model backed the monolithic audit_events table. All new audit event writes now go to the four scoped tables via AuditEvents::GroupAuditEvent, AuditEvents::ProjectAuditEvent, AuditEvents::UserAuditEvent, and AuditEvents::InstanceAuditEvent. The legacy model is no longer written to and can be safely removed from application code.

Changes:

  • Deleted app/models/audit_event.rb and ee/app/models/ee/audit_event.rb
  • AuditEvents::Processor: removed the ::AuditEvent.find_by_id fallback in fetch_from_id; a nil model_class now returns nil immediately
  • AuditEventPresenter: replaced presents ::AuditEvent, as: :audit_event with an explicit audit_event accessor method (the presenter is still used by all scoped models via their present methods)
  • User model: removed has_many :audit_events association; removed the matching inverse_of: :audit_events from CommonModel#belongs_to :user
  • Specs: deleted spec/models/audit_event_spec.rb and ee/spec/models/ee/audit_event_spec.rb
  • Factory: deleted spec/factories/audit_events.rb (the legacy :audit_event factory and its sub-factory aliases :project_audit_event, :group_audit_event, :instance_audit_event, :user_audit_event); all callers updated to use the scoped :audit_events_*_audit_event factories
  • EE specs: updated all specs that used create/build(:audit_event, ...) or the legacy factory aliases to use scoped factories
  • Streaming shared examples: removed table-test rows that compared legacy AuditEvent records to scoped-model records
  • Auditor specs: replaced AuditEvent.count assertions with AuditEventReader.count (reads across all scoped tables)

Not in scope: The audit_events table itself is NOT dropped. That is tracked separately in #512026.

References

Screenshots or screen recordings

Not applicable — no UI changes.

How to set up and validate locally

  1. Run the affected specs:
    • bin/rspec spec/services/audit_events/processor_spec.rb
    • bin/rspec spec/lib/gitlab/audit/auditor_spec.rb
    • bin/rspec spec/lib/gitlab/audit/null_author_spec.rb
    • bin/rspec ee/spec/presenters/audit_event_presenter_spec.rb
    • bin/rspec ee/spec/serializers/audit_event_entity_spec.rb
    • bin/rspec ee/spec/lib/gitlab/audit/auditor_spec.rb
  2. Verify the app boots: bin/rails runner "puts 'OK'"

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Duo Developer

Merge request reports

Loading
Loading