parabol
parabol copied to clipboard
chore: normalize data in PG across tables
We've gotten into a pretty bad habit of denormalizing data across tables. This makes updates tricky because you have to update the field in multiple tables!
Here are some culprits I've found that we should remove. As we find more we should add them here & try really hard to have a single source of truth!
-
Organization.tier
(truth) -
User.tier
-
OrganizationUser.tier
-
Organization.trialStartDate
(truth) -
OrganizationUser.trialStartDate
-
Team.trialStartDate
-
User.trialStartDate
(🫤 denormalized across 4 tables total?!) -
User.picture
(truth) -
TeamMember.picture
-
User.preferredName
(truth) -
TeamMember.preferredName
-
User.inactive
(truth) -
Organization.inactive
-
Organization.isPaid
(truth) -
Team.isPaid
-
User.tms
(TeamMember is truth)
AC
- [ ] refactor setUserTierForUserIds, setUserTierForOrgId, setTierForOrgUsers