Add default database value for notified_of_own_activity column
What does this MR do and why?
We replaced default_value_for gem with the native rails implementation in f124341c. We added some setters and getters to ensure the same behavior. After adding the default for columns, we need to backfill the null values and then remove the setters and getters which is a bit hacky way to make this work.
For other columns changed in f124341c defaults are already present.
Migration output
up
bin/rails db:migrate
WARNING: This version of GitLab depends on gitlab-shell 14.22.0, but you're running 14.20.0. Please update gitlab-shell.
main: == [advisory_lock_connection] object_id: 227880, pg_backend_pid: 67824
main: == 20230602131429 ChangeNotifiedOfOwnActivityDefault: migrating ===============
main: -- change_column_default(:users, :notified_of_own_activity, {:from=>nil, :to=>false})
main: -> 0.1414s
main: == 20230602131429 ChangeNotifiedOfOwnActivityDefault: migrated (0.1491s) ======
main: == [advisory_lock_connection] object_id: 227880, pg_backend_pid: 67824
ci: == [advisory_lock_connection] object_id: 228100, pg_backend_pid: 67827
ci: == 20230602131429 ChangeNotifiedOfOwnActivityDefault: migrating ===============
ci: -- change_column_default(:users, :notified_of_own_activity, {:from=>nil, :to=>false})
ci: -> 0.0069s
ci: == 20230602131429 ChangeNotifiedOfOwnActivityDefault: migrated (0.0217s) ======
down
bin/rails db:rollback:ci && bin/rails db:rollback:main
WARNING: This version of GitLab depends on gitlab-shell 14.22.0, but you're running 14.20.0. Please update gitlab-shell.
ci: == [advisory_lock_connection] object_id: 227640, pg_backend_pid: 69601
ci: == 20230602131429 ChangeNotifiedOfOwnActivityDefault: reverting ===============
ci: -- change_column_default(:users, :notified_of_own_activity, {:from=>false, :to=>nil})
ci: -> 0.1374s
ci: == 20230602131429 ChangeNotifiedOfOwnActivityDefault: reverted (0.1722s) ======
ci: == [advisory_lock_connection] object_id: 227640, pg_backend_pid: 69601
WARNING: This version of GitLab depends on gitlab-shell 14.22.0, but you're running 14.20.0. Please update gitlab-shell.
main: == [advisory_lock_connection] object_id: 227620, pg_backend_pid: 70203
main: == 20230602131429 ChangeNotifiedOfOwnActivityDefault: reverting ===============
main: -- change_column_default(:users, :notified_of_own_activity, {:from=>false, :to=>nil})
main: -> 0.2586s
main: == 20230602131429 ChangeNotifiedOfOwnActivityDefault: reverted (0.2951s) ======
main: == [advisory_lock_connection] object_id: 227620, pg_backend_pid: 70203
How to set up and validate locally
Run bin/rails db:migrate
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 #382704 (closed)