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.rbandee/app/models/ee/audit_event.rb AuditEvents::Processor: removed the::AuditEvent.find_by_idfallback infetch_from_id; a nilmodel_classnow returns nil immediatelyAuditEventPresenter: replacedpresents ::AuditEvent, as: :audit_eventwith an explicitaudit_eventaccessor method (the presenter is still used by all scoped models via theirpresentmethods)Usermodel: removedhas_many :audit_eventsassociation; removed the matchinginverse_of: :audit_eventsfromCommonModel#belongs_to :user- Specs: deleted
spec/models/audit_event_spec.rbandee/spec/models/ee/audit_event_spec.rb - Factory: deleted
spec/factories/audit_events.rb(the legacy:audit_eventfactory 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_eventfactories - 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
AuditEventrecords to scoped-model records - Auditor specs: replaced
AuditEvent.countassertions withAuditEventReader.count(reads across all scoped tables)
Not in scope: The audit_events table itself is NOT dropped. That is tracked separately in #512026.
References
- Closes #615798 (closed)
- Related table drop: #512026
Screenshots or screen recordings
Not applicable — no UI changes.
How to set up and validate locally
- Run the affected specs:
bin/rspec spec/services/audit_events/processor_spec.rbbin/rspec spec/lib/gitlab/audit/auditor_spec.rbbin/rspec spec/lib/gitlab/audit/null_author_spec.rbbin/rspec ee/spec/presenters/audit_event_presenter_spec.rbbin/rspec ee/spec/serializers/audit_event_entity_spec.rbbin/rspec ee/spec/lib/gitlab/audit/auditor_spec.rb
- 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.