-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix how we store Musician Groups (#90)
* first pass * maybe fix tests * fix tests maybe * fix schema * format * remvoe role from group member * remove unces todo
- Loading branch information
Showing
7 changed files
with
104 additions
and
69 deletions.
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 () => { | ||
|