Skip to content

Delegate profile fields to user details

What does this MR do and why?

Have User call UserDetail for

  • linkedin
  • twitter
  • skype
  • website_url
  • location
  • organization

and mark those columns for removal in User. Migrations to drop the columns will be added in a future MR.

Previously, in !95107 (merged) and !101830 (merged), these fields were synced to their user_details counterparts. This MR should only be merged to the milestone after those MRs are released (I believe 15.7).

rake db:migrate

main: == 20221102231131 RemoveTempIndexForUserDetailsFields: migrating ==============
main: -- transaction_open?()
main:    -> 0.0000s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- indexes(:users)
main:    -> 0.0179s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0004s
main: -- remove_index(:users, {:algorithm=>:concurrently, :name=>"tmp_idx_where_user_details_fields_filled"})
main:    -> 0.0019s
main: -- execute("RESET statement_timeout")
main:    -> 0.0003s
main: == 20221102231131 RemoveTempIndexForUserDetailsFields: migrated (0.0520s) =====

rake db:rollback

main: == 20221102231131 RemoveTempIndexForUserDetailsFields: reverting ==============
main: -- transaction_open?()
main:    -> 0.0000s
main: -- index_exists?(:users, :id, {:name=>"tmp_idx_where_user_details_fields_filled", :where=>"(COALESCE(linkedin, '') IS DISTINCT FROM '')\nOR (COALESCE(twitter, '') IS DISTINCT FROM '')\nOR (COALESCE(skype, '') IS DISTINCT FROM '')\nOR (COALESCE(website_url, '') IS DISTINCT FROM '')\nOR (COALESCE(location, '') IS DISTINCT FROM '')\nOR (COALESCE(organization, '') IS DISTINCT FROM '')\n", :algorithm=>:concurrently})
main:    -> 0.0240s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0004s
main: -- add_index(:users, :id, {:name=>"tmp_idx_where_user_details_fields_filled", :where=>"(COALESCE(linkedin, '') IS DISTINCT FROM '')\nOR (COALESCE(twitter, '') IS DISTINCT FROM '')\nOR (COALESCE(skype, '') IS DISTINCT FROM '')\nOR (COALESCE(website_url, '') IS DISTINCT FROM '')\nOR (COALESCE(location, '') IS DISTINCT FROM '')\nOR (COALESCE(organization, '') IS DISTINCT FROM '')\n", :algorithm=>:concurrently})
main:    -> 0.0034s
main: -- execute("RESET statement_timeout")
main:    -> 0.0004s
main: == 20221102231131 RemoveTempIndexForUserDetailsFields: reverted (0.0393s) =====

How to set up and validate locally

In a Rails console, set each of the fields on a user. Verify the fields were saved properly. For example

[1] pry(main)> u = User.last
[2] pry(main)> u.website_url = 'http://example.com'
[3] pry(main)> u.save!
[4] pry(main)> u.website_url
=> "http://example.com"
[5] pry(main)> u.user_detail.website_url
=> "http://example.com"

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 #206913 (closed)

Edited by Brian Austin

Merge request reports