chore: Chore team metadata table + isOrganization migration from metadata#12828
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
5 Ignored Deployments
|
|
Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link. |
| -- Set team field to notify if it is an organization -> Easier than metadata.parse(X).isOrganization | ||
| UPDATE "Team" | ||
| SET "isOrganization" = (metadata ->> 'isOrganization')::BOOLEAN | ||
| WHERE | ||
| metadata ->> 'isOrganization' = 'true'; | ||
|
|
||
| -- Insert data into org settings | ||
| INSERT INTO "OrganizationSettings" ("teamId", "isOrganizationConfigured", "orgAutoAcceptEmail", "isOrganizationVerified") | ||
| SELECT | ||
| t.id, | ||
| (t.metadata ->> 'isOrganizationConfigured')::BOOLEAN AS "isOrganizationConfigured", | ||
| t.metadata ->> 'orgAutoAcceptEmail' AS "orgAutoAcceptEmail", | ||
| (t.metadata ->> 'isOrganizationVerified')::BOOLEAN AS "isOrganizationVerified" | ||
| FROM ( | ||
| SELECT | ||
| id, | ||
| metadata | ||
| FROM | ||
| "Team" | ||
| WHERE | ||
| metadata ->> 'isOrganization' = 'true' | ||
| ) AS t; No newline at end of file |
There was a problem hiding this comment.
important:
Here we are just updating a table - we are not removing or deleting this data from metadata FOR NOW.
Once we have ran this custom migration we can consider removing the existing fields in prod db to ensure we dont have duplicated data.
📦 Next.js Bundle Analysis for @calcom/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖 Three Pages Changed SizeThe following pages changed size from the code in this PR compared to its base branch:
DetailsOnly the gzipped size is provided here based on an expert tip. First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If Any third party scripts you have added directly to your app using the The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored. |
| metadata: { | ||
| ...metaDataParsed, | ||
| isOrganizationVerified: true, | ||
| orgAutoAcceptEmail: acceptedEmailDomain, | ||
| }, |
There was a problem hiding this comment.
We no longer need to update metadata for this as it is handled in organizationSettings
| const team = await getTeamOrThrow(input.teamId); | ||
|
|
||
| const isOrg = team.isOrganization; |
There was a problem hiding this comment.
Switched this order around so we can get if it is an organization based on teamId
@ThyMinimalDev can you confirm this is the correct logic here?
There was a problem hiding this comment.
makes sense, probably better to check if the team is an org from database rathe than relying on input parameter
There was a problem hiding this comment.
@ThyMinimalDev given the changes in inviteHandler do these changes look fine to you?
…chore-team-metadata-table
|
|
||
| const nonOrgTeams = user.teams | ||
| .filter((membership) => !isOrganization({ team: membership.team })) | ||
| .filter((membership) => !membership.team.isOrganization) |
There was a problem hiding this comment.
I don't see a reason to switch away from isOrganization
| .filter((membership) => !membership.team.isOrganization) | |
| .filter((membership) => !isOrganization({team:membership.team}) |
…handler.ts Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
…handler.ts Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
hariombalhara
left a comment
There was a problem hiding this comment.
Awesome work @sean-brydon 🙏 Thanks for the PR
|
Heads up. the migration in this PR is failing on prod. Blocking the latest release. |
| CREATE UNIQUE INDEX "OrganizationSettings_organizationId_key" ON "OrganizationSettings"("organizationId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE UNIQUE INDEX "Team_slug_isOrganization_key" ON "Team"("slug", "isOrganization"); |
There was a problem hiding this comment.
ERROR: could not create unique index "Team_slug_isOrganization_key"
DETAIL: Key (slug, "isOrganization")=(advisors, f) is duplicated.
|
@calcom/foundation @sean-brydon had to revert this PR due to migration not being compatible with actual prod data. Causing it to fail. |
|
From internal chat:
|
What does this PR do?
Type of change
How should this be tested?
WHERE "id" in (1,2,3);
UPDATE "Team" SET "isOrganization" = true WHERE "id" in (1,2,3);
Mandatory Tasks
Checklist