The source project of this merge request has been removed.
Sync profile fields to user_details and truncate
What does this MR do and why?
Adds the following fields to user_details
with ActiveRecord hooks to sync values between user.<field_name>
and user.user_detail.<field_name>
on update.
- skype
- website_url
- location
- organization
Note: the sync to the user_details
will truncate values for those fields that are above 500 characters. The original data will stick around until a future release when the user
fields are removed.
More information about the amended process can be found in !93298 (comment 1044564813).
Screenshots or screen recordings
db:migrate
output
$ scripts/db_tasks db:migrate
main: == 20220802200719 AddUserDetailsProfileFields: migrating ======================
main: -- add_column(:user_details, :linkedin, :text, {:null=>false, :default=>""})
main: -> 0.0040s
main: -- add_column(:user_details, :twitter, :text, {:null=>false, :default=>""})
main: -> 0.0050s
main: -- add_column(:user_details, :skype, :text, {:null=>false, :default=>""})
main: -> 0.0026s
main: -- add_column(:user_details, :website_url, :text, {:null=>false, :default=>""})
main: -> 0.0036s
main: -- add_column(:user_details, :location, :text, {:null=>false, :default=>""})
main: -> 0.0029s
main: -- add_column(:user_details, :organization, :text, {:null=>false, :default=>""})
main: -> 0.0023s
main: == 20220802200719 AddUserDetailsProfileFields: migrated (0.0228s) =============
main: == 20220802202505 AddUserDetailsFieldLimits: migrating ========================
main: -- transaction_open?()
main: -> 0.0000s
main: -- current_schema()
main: -> 0.0007s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE user_details\nADD CONSTRAINT check_7d6489f8f3\nCHECK ( char_length(linkedin) <= 50 )\nNOT VALID;\n")
main: -> 0.0016s
main: -- current_schema()
main: -> 0.0007s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0006s
main: -- execute("ALTER TABLE user_details VALIDATE CONSTRAINT check_7d6489f8f3;")
main: -> 0.0011s
main: -- execute("RESET statement_timeout")
main: -> 0.0007s
main: -- transaction_open?()
main: -> 0.0000s
main: -- current_schema()
main: -> 0.0004s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE user_details\nADD CONSTRAINT check_466a25be35\nCHECK ( char_length(twitter) <= 50 )\nNOT VALID;\n")
main: -> 0.0020s
main: -- current_schema()
main: -> 0.0005s
main: -- execute("ALTER TABLE user_details VALIDATE CONSTRAINT check_466a25be35;")
main: -> 0.0011s
main: -- transaction_open?()
main: -> 0.0000s
main: -- current_schema()
main: -> 0.0004s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE user_details\nADD CONSTRAINT check_444573ee52\nCHECK ( char_length(skype) <= 50 )\nNOT VALID;\n")
main: -> 0.0015s
main: -- current_schema()
main: -> 0.0005s
main: -- execute("ALTER TABLE user_details VALIDATE CONSTRAINT check_444573ee52;")
main: -> 0.0011s
main: -- transaction_open?()
main: -> 0.0000s
main: -- current_schema()
main: -> 0.0006s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE user_details\nADD CONSTRAINT check_7fe2044093\nCHECK ( char_length(website_url) <= 255 )\nNOT VALID;\n")
main: -> 0.0012s
main: -- current_schema()
main: -> 0.0004s
main: -- execute("ALTER TABLE user_details VALIDATE CONSTRAINT check_7fe2044093;")
main: -> 0.0014s
main: -- transaction_open?()
main: -> 0.0000s
main: -- current_schema()
main: -> 0.0007s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE user_details\nADD CONSTRAINT check_8a7fcf8a60\nCHECK ( char_length(location) <= 255 )\nNOT VALID;\n")
main: -> 0.0010s
main: -- current_schema()
main: -> 0.0004s
main: -- execute("ALTER TABLE user_details VALIDATE CONSTRAINT check_8a7fcf8a60;")
main: -> 0.0010s
main: -- transaction_open?()
main: -> 0.0000s
main: -- current_schema()
main: -> 0.0005s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE user_details\nADD CONSTRAINT check_7b246dad73\nCHECK ( char_length(organization) <= 255 )\nNOT VALID;\n")
main: -> 0.0009s
main: -- current_schema()
main: -> 0.0004s
main: -- execute("ALTER TABLE user_details VALIDATE CONSTRAINT check_7b246dad73;")
main: -> 0.0015s
main: == 20220802202505 AddUserDetailsFieldLimits: migrated (0.0886s) ===============
db:rollback
output
(Note: I'm using db:migrate:down VERSION=?
for this due to some migrations added later)
$ scripts/db_tasks db:migrate:down VERSION=20220802202505
main: == 20220802202505 AddUserDetailsFieldLimits: reverting ========================
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE user_details\nDROP CONSTRAINT IF EXISTS check_7d6489f8f3\n")
main: -> 0.0017s
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE user_details\nDROP CONSTRAINT IF EXISTS check_466a25be35\n")
main: -> 0.0010s
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE user_details\nDROP CONSTRAINT IF EXISTS check_444573ee52\n")
main: -> 0.0011s
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE user_details\nDROP CONSTRAINT IF EXISTS check_7fe2044093\n")
main: -> 0.0011s
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE user_details\nDROP CONSTRAINT IF EXISTS check_8a7fcf8a60\n")
main: -> 0.0011s
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE user_details\nDROP CONSTRAINT IF EXISTS check_7b246dad73\n")
main: -> 0.0009s
main: == 20220802202505 AddUserDetailsFieldLimits: reverted (0.0373s) ===============
$ scripts/db_tasks db:migrate:down VERSION=20220802200719
main: == 20220802200719 AddUserDetailsProfileFields: reverting ======================
main: -- remove_column(:user_details, :organization, :text, {:null=>false, :default=>""})
main: -> 0.0042s
main: -- remove_column(:user_details, :location, :text, {:null=>false, :default=>""})
main: -> 0.0017s
main: -- remove_column(:user_details, :website_url, :text, {:null=>false, :default=>""})
main: -> 0.0022s
main: -- remove_column(:user_details, :skype, :text, {:null=>false, :default=>""})
main: -> 0.0020s
main: -- remove_column(:user_details, :twitter, :text, {:null=>false, :default=>""})
main: -> 0.0022s
main: -- remove_column(:user_details, :linkedin, :text, {:null=>false, :default=>""})
main: -> 0.0016s
main: == 20220802200719 AddUserDetailsProfileFields: reverted (0.0181s) =============
How to set up and validate locally
- Login as the root user
- Set a value for LinkedIn on the edit profile page
- Check to make sure the value was set on
user_details
in the rails console:User.first.user_detail.linkedin
- Repeat for the other fields.
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 #206913 (closed)
Edited by Brian Austin