Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add migrations for upcoming activities for commands/profiles #17472

Merged
merged 10 commits into from Mar 14, 2024

Conversation

roperzh
Copy link
Member

@roperzh roperzh commented Mar 7, 2024

#16830

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Added/updated tests
  • If database migrations are included, checked table schema to confirm autoupdate
  • For database migrations:
    • Checked schema for all modified table for columns that will auto-update timestamps during migration.
    • Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects.
  • Manual QA for all new/changed functionality

Copy link

codecov bot commented Mar 7, 2024

Codecov Report

Attention: Patch coverage is 77.27273% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 65.60%. Comparing base (5c72cea) to head (4243e9d).

Files Patch % Lines
...01544_TrackUserReferencesForCommandsAndProfiles.go 80.00% 10 Missing and 4 partials ⚠️
server/datastore/mysql/users.go 66.66% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##           feat-ua-commands   #17472      +/-   ##
====================================================
+ Coverage             65.58%   65.60%   +0.01%     
====================================================
  Files                  1193     1194       +1     
  Lines                107927   108014      +87     
  Branches               2568     2568              
====================================================
+ Hits                  70788    70865      +77     
- Misses                31759    31767       +8     
- Partials               5380     5382       +2     
Flag Coverage Δ
backend 66.60% <77.27%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

INSERT INTO user_persistent_info (user_id, user_name)
SELECT id, name
FROM users
`)
Copy link
Member Author

@roperzh roperzh Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two questions:

  1. should we drop users.name and force people to JOIN using this table?
  2. if we don't do 1 should we use a db trigger? I know we avoid those but I don't remember why (maybe performance for the hosts table?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good questions... Would it be very hard to avoid both? I.e. keep the mirrored info (as we also do for activities I think?), and avoid the trigger by making sure the updates of users also update that table in a transaction?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me! ended up going with that.

@roperzh roperzh changed the title add migrations for commands add migrations for upcoming activities for commands/profiles Mar 13, 2024
Copy link
Member

@mna mna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Really like the approach you chose.

user_id int(10) unsigned DEFAULT NULL,

-- user_name mirrors the users.name value
user_name varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also mirror the gravatar_url? On second thought probably not, I see the activities table doesn't have it (thought it did for some reason).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, but I think we compute the gravatar from the email, I will sanity check and include the email as well.

INSERT INTO user_persistent_info (user_id, user_name)
SELECT id, name
FROM users
`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good questions... Would it be very hard to avoid both? I.e. keep the mirrored info (as we also do for activities I think?), and avoid the trigger by making sure the updates of users also update that table in a transaction?

ALTER TABLE`+" `%s` "+`
ADD CONSTRAINT`+" `fk_%s_user_info` "+`
FOREIGN KEY (user_persistent_info_id) REFERENCES user_persistent_info(id)
ON DELETE RESTRICT`, t, t))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DELETE RESTRICT is basically to prevent a deletion to user_persistent_info, which should never happen, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's exactly right! just as an extra precaution.

@roperzh roperzh marked this pull request as ready for review March 14, 2024 13:28
@roperzh roperzh requested a review from a team as a code owner March 14, 2024 13:28
jahzielv
jahzielv previously approved these changes Mar 14, 2024
@roperzh roperzh changed the base branch from main to feat-ua-commands March 14, 2024 13:57
Copy link
Contributor

@jahzielv jahzielv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roperzh roperzh merged commit ba19afd into feat-ua-commands Mar 14, 2024
17 checks passed
@roperzh roperzh deleted the 16830-ua-db branch March 14, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants