Event default scope adds an unnecessary WHERE author_is IS NOT NULL condition
Looking at our production database the author_id column is always set, thus the filter WHERE author_id IS NOT NULL is redundant and can even result in less ideal query plans. We should:
- Add
validates :author_id, presence: truetoEvent(don't usevalidates :authorsince this will do a query which is redundant as this should be taken care of using a foreign key) - Add a foreign key on
events.author_idpointing tousers.idwith a cascading delete - Remove the WHERE from the default scope
See https://gitlab.com/gitlab-org/gitlab-ce/issues/31806 for more info.