Validate the presence of default User and UserPreference attributes
What does this MR do and why?
This MR reinstates the MR that was reverted !126013 (merged) because the original MR caused an incident gitlab-com/gl-infra/production#16022 (closed). The root cause of the incident was that the newly added validations were failing for existing records.
All the existing records should now get updated in !125881 (merged) and !125774 (merged). This MR should be deployed only after these background migrations have been finalized and we have verified that there are no records with null attributes according to our database migration guideline https://docs.gitlab.com/ee/development/database/not_null_constraints.html#check-if-all-records-are-fixed-next-release.
Summary of changes
How to set up and validate locally
Open the rails console and you should not be able to set the attributes to nil:
user = User.first
user.hide_no_ssh_key = nil
user.save!
=> ActiveRecord::RecordInvalid: Validation failed: Hide no ssh key is not included in the list
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #417576 (closed)