500 Error when logging in after upgrading from 13.3.9 to 13.4.7

I just upgraded an instance of gitlab-ce from version 13.3.9 to version 13.4.7, and am now getting a 500 error when a user tries to log in.

I looked in the logs using sudo gitlab-ctl tail, and this is the traceback:

==> /var/log/gitlab/gitlab-rails/production.log <==
 
ActiveModel::MissingAttributeError (can't write unknown attribute `target_type`):
 
app/models/audit_event.rb:82:in `block in parallel_persist'
app/models/audit_event.rb:82:in `each'
app/models/audit_event.rb:82:in `parallel_persist'
app/services/audit_event_service.rb:112:in `log_security_event_to_database'
app/services/audit_event_service.rb:46:in `security_event'
app/controllers/sessions_controller.rb:272:in `log_audit_event'
app/controllers/sessions_controller.rb:77:in `block in create'
app/controllers/sessions_controller.rb:62:in `create'
app/controllers/application_controller.rb:491:in `set_current_admin'
lib/gitlab/session.rb:11:in `with_session'
app/controllers/application_controller.rb:482:in `set_session_storage'
lib/gitlab/i18n.rb:73:in `with_locale'
lib/gitlab/i18n.rb:79:in `with_user_locale'
app/controllers/application_controller.rb:476:in `set_locale'
lib/gitlab/error_tracking.rb:52:in `with_context'
app/controllers/application_controller.rb:541:in `sentry_context'
app/controllers/application_controller.rb:469:in `block in set_current_context'
lib/gitlab/application_context.rb:52:in `block in use'
lib/gitlab/application_context.rb:52:in `use'
lib/gitlab/application_context.rb:20:in `with_context'
app/controllers/application_controller.rb:462:in `set_current_context'
lib/gitlab/request_profiler/middleware.rb:17:in `call'
lib/gitlab/jira/middleware.rb:19:in `call'
lib/gitlab/middleware/go.rb:20:in `call'
lib/gitlab/etag_caching/middleware.rb:13:in `call'
lib/gitlab/middleware/multipart.rb:233:in `call'
lib/gitlab/middleware/read_only/controller.rb:51:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/same_site_cookies.rb:27:in `call'
lib/gitlab/middleware/basic_health_check.rb:25:in `call'
lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'
lib/gitlab/middleware/request_context.rb:23:in `call'
config/initializers/fix_local_cache_middleware.rb:9:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:60:in `call'
lib/gitlab/middleware/release_env.rb:12:in `call'

I searched online but it doesn’t seem anyone has had this particular error. Already logged-in users can use it fine as long as they don’t log out, and git pull and clone and such still work. Just the web app login is broken.