Skip to content

Migration for backfilling of columns with null values to the default value

In !102897 (merged) we've replaced default_value_for with Rails native implementation. The database allows NULL values and there are a few million records with NULL values. We should backfill those columns with default column values, set a column default with NOT NULL constraints, and corresponding model behaviour.

Implementation plan

Migration for backfilling of columns with null values to the default value.

There are 1423697 rows which will need to be updated as per

gitlabhq_dblab=# select count(*) from users where (admin is null) or (external is null) or (can_create_group is null) or (can_create_team is null) or (hide_no_ssh_key is null) or (hide_no_password is null) or (project_view is null) or (notified_of_own_activity is null) or (preferred_language is null) or (theme_id is null) limit 1;

  count
---------
 1423697
(1 row)
Edited by Christina Lohr