-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1095 from rockingrohit9639/feature/owner-team-member
Feature/owner team member
- Loading branch information
Showing
6 changed files
with
75 additions
and
52 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...ns/20240625083758_insert_teammembers_for_all_org_owners_without_team_member/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- It is used to insert team members for all organization owners who do not have a team member record. | ||
-- To test if the migration works, you can run the same query without the first line (INSERT INTO "TeamMember" ...) and check the results. | ||
INSERT INTO "TeamMember" (id, name, "organizationId", "userId", "createdAt", "updatedAt") | ||
SELECT | ||
'c' || md5(random()::text || clock_timestamp()::text)::uuid, -- Simulates cuid generation | ||
COALESCE(u."firstName", '') || ' ' || COALESCE(u."lastName", ''), -- Combines first name and last name, replacing NULL with empty string | ||
o.id, -- Organization ID | ||
o."userId", -- User ID | ||
NOW(), -- Current timestamp for createdAt | ||
NOW() -- Current timestamp for updatedAt | ||
FROM | ||
"Organization" o | ||
LEFT JOIN "TeamMember" tm ON o.id = tm."organizationId" AND o."userId" = tm."userId" | ||
JOIN "User" u ON o."userId" = u.id | ||
WHERE | ||
tm.id IS NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters