Migrate users.private_profile so it does not allow NULL values
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24690 introduces some queries that use users.private_profile
. Since this column can be NULL, the possible values are {TRUE,FALSE,NULL}
. This makes the queries more complicated and less efficient.
To resolve this we need to migrate this column so that it no longer allows NULL values. Since we have quite a few users, we can not update all of them in a regular migration, as this could cause database problems. Instead, we need a background migration, and two releases:
- Release 1 schedules the background migration, and includes code changes to populate the column with a default boolean (instead of
nil
) - Release 2 finishes the remaining background migration jobs, performs an additional UPDATE to take care of any rows we might have missed (this should be close to zero), then adds a NOT NULL constraint. Adding the NOT NULL constraint must be performed outside of the transaction(s) used for updating rows, otherwise we would hold on to the row locks for too long.