-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix how we store Musician Groups #90
Merged
owens1127
merged 7 commits into
main
from
37-replace-groups-invites-objects-in-the-database
Jan 26, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c054ee3
first pass
owens1127 dc0ed96
maybe fix tests
owens1127 7e8fdf1
fix tests maybe
owens1127 badbada
fix schema
owens1127 e2d2228
format
owens1127 6f9141f
remvoe role from group member
owens1127 17bb5c9
remove unces todo
owens1127 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
62 changes: 62 additions & 0 deletions
62
packages/db/prisma/migrations/20250125001713_refactor_groups/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,62 @@ | ||
/* | ||
Warnings: | ||
|
||
- You are about to drop the `Group` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `GroupInvite` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `_GroupToUser` table. If the table is not empty, all the data it contains will be lost. | ||
|
||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "GroupInvite" DROP CONSTRAINT "GroupInvite_groupId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "GroupInvite" DROP CONSTRAINT "GroupInvite_initiatorId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "_GroupToUser" DROP CONSTRAINT "_GroupToUser_A_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "_GroupToUser" DROP CONSTRAINT "_GroupToUser_B_fkey"; | ||
|
||
-- DropTable | ||
DROP TABLE "Group"; | ||
|
||
-- DropTable | ||
DROP TABLE "GroupInvite"; | ||
|
||
-- DropTable | ||
DROP TABLE "_GroupToUser"; | ||
|
||
-- CreateTable | ||
CREATE TABLE "MusicianGroup" ( | ||
"groupId" TEXT NOT NULL, | ||
"organizerId" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "MusicianGroup_pkey" PRIMARY KEY ("groupId") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "MusicianGroupMember" ( | ||
"groupId" TEXT NOT NULL, | ||
"firstName" TEXT NOT NULL, | ||
"lastName" TEXT NOT NULL, | ||
"stageName" TEXT, | ||
"email" TEXT NOT NULL, | ||
"isSongWriter" BOOLEAN NOT NULL DEFAULT false, | ||
"isAscapAffiliated" BOOLEAN NOT NULL DEFAULT false, | ||
"isBmiAffiliated" BOOLEAN NOT NULL DEFAULT false, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "MusicianGroupMember_groupId_email_key" ON "MusicianGroupMember"("groupId", "email"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "MusicianGroup" ADD CONSTRAINT "MusicianGroup_organizerId_fkey" FOREIGN KEY ("organizerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "MusicianGroupMember" ADD CONSTRAINT "MusicianGroupMember_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "MusicianGroup"("groupId") ON DELETE CASCADE ON UPDATE CASCADE; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,7 +90,7 @@ describe("get user", () => { | |
}, | ||
}, | ||
}), | ||
prisma.group.deleteMany({ | ||
prisma.musicianGroup.deleteMany({ | ||
where: { | ||
name: "Owen's Group", | ||
}, | ||
|
@@ -136,18 +136,18 @@ describe("get user", () => { | |
expect(response.message).toEqual("Successfully onboarded"); | ||
expect(mockCache.revalidatePath).toHaveBeenCalledWith("/onboarding"); | ||
|
||
const group = await prisma.group.findFirst({ | ||
const group = await prisma.musicianGroup.findFirst({ | ||
where: { | ||
name: "Owen's Group", | ||
}, | ||
include: { | ||
invites: true, | ||
groupMembers: true, | ||
}, | ||
}); | ||
|
||
expect(group).not.toBeNull(); | ||
expect(group?.invites).toHaveLength(1); | ||
expect(group?.invites[0]?.email).toEqual("[email protected]"); | ||
expect(group?.groupMembers).toHaveLength(1); | ||
expect(group?.groupMembers[0]?.email).toEqual("[email protected]"); | ||
}); | ||
|
||
test("Onboards media maker", async () => { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we need to update this data on creation/update of its user (in case the wrong data is inputted), or is this more of a one time use data for registration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's the former, where we want to display updated data in the admin dashboard so that the admin can view the updated information for group members, we may need to make a table to associate MusicianGroupMember with User.