Skip to content

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

MR Step
Fill null values of users table with their defa... (!125881 - merged) 1
Finalize batched background migrations (!132480 - merged) 2 & 3
Validate the presence of default User and UserP... (!127587 - merged) 4 👈 You are here
Prevent adding new records with null attributes (!125744 - merged) 5

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.

Related to #417576 (closed)

Edited by Abdul Wadood

Merge request reports

Loading