-
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.
* mirgations * attempt to fix env * fix type errs * syntax err in migration * fix syntax errs part 2 * create group schema * fix types * add createdAt to groupInvite * add id to group invite --------- Co-authored-by: DamianUduevbo <[email protected]>
- Loading branch information
1 parent
58c66a4
commit f13e74c
Showing
13 changed files
with
195 additions
and
75 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
16 changes: 16 additions & 0 deletions
16
packages/db/prisma/migrations/20241031000211_new_user_fields/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 @@ | ||
-- CreateEnum | ||
CREATE TYPE "Role" AS ENUM ('MUSICIAN', 'MEDIA_MAKER', 'ADMIN'); | ||
|
||
-- AlterTable | ||
ALTER TABLE "User" | ||
RENAME COLUMN "name" TO "firstName"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "User" | ||
ADD COLUMN "lastName" TEXT NOT NULL DEFAULT '', | ||
ADD COLUMN "role" "Role" NOT NULL DEFAULT 'MEDIA_MAKER'; | ||
|
||
-- RemoveDefault | ||
ALTER TABLE "User" | ||
ALTER COLUMN "lastName" DROP DEFAULT, | ||
ALTER COLUMN "role" DROP DEFAULT; |
47 changes: 47 additions & 0 deletions
47
packages/db/prisma/migrations/20241103222852_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,47 @@ | ||
-- CreateTable | ||
CREATE TABLE "Group" ( | ||
"groupId" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "Group_pkey" PRIMARY KEY ("groupId") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "GroupInvite" ( | ||
"id" TEXT NOT NULL, | ||
"groupId" TEXT NOT NULL, | ||
"intitiatorId" TEXT NOT NULL, | ||
"email" TEXT NOT NULL, | ||
"firstName" TEXT NOT NULL, | ||
"lastName" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "_GroupToUser" ( | ||
"A" TEXT NOT NULL, | ||
"B" TEXT NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "GroupInvite_groupId_email_key" ON "GroupInvite"("groupId", "email"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "_GroupToUser_AB_unique" ON "_GroupToUser"("A", "B"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "_GroupToUser_B_index" ON "_GroupToUser"("B"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "GroupInvite" ADD CONSTRAINT "GroupInvite_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "Group"("groupId") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "GroupInvite" ADD CONSTRAINT "GroupInvite_intitiatorId_fkey" FOREIGN KEY ("intitiatorId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_GroupToUser" ADD CONSTRAINT "_GroupToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Group"("groupId") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_GroupToUser" ADD CONSTRAINT "_GroupToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ async function main() { | |
update: { | ||
sessions: { | ||
update: { | ||
where: { id: "23" }, | ||
where: { sessionId: "23" }, | ||
data: { | ||
expiresAt: new Date( | ||
new Date().setFullYear(new Date().getFullYear() + 10), | ||
|
@@ -20,13 +20,15 @@ async function main() { | |
}, | ||
}, | ||
create: { | ||
id: "7", | ||
userId: "7", | ||
email: "[email protected]", | ||
name: "Alice", | ||
firstName: "Alice", | ||
lastName: "Smith", | ||
role: "MEDIA_MAKER", | ||
hashedPassword: await hashPassword("alicePassword"), | ||
sessions: { | ||
create: { | ||
id: "23", | ||
sessionId: "23", | ||
expiresAt: new Date( | ||
new Date().setFullYear(new Date().getFullYear() + 10), | ||
), | ||
|
@@ -42,15 +44,15 @@ async function main() { | |
sessions: { | ||
updateMany: [ | ||
{ | ||
where: { id: "12" }, | ||
where: { sessionId: "12" }, | ||
data: { | ||
expiresAt: new Date( | ||
new Date().setFullYear(new Date().getFullYear() - 1), | ||
), | ||
}, | ||
}, | ||
{ | ||
where: { id: "45" }, | ||
where: { sessionId: "45" }, | ||
data: { | ||
expiresAt: new Date( | ||
new Date().setFullYear(new Date().getFullYear() + 10), | ||
|
@@ -61,21 +63,23 @@ async function main() { | |
}, | ||
}, | ||
create: { | ||
id: "9", | ||
userId: "9", | ||
email: "[email protected]", | ||
name: "Bob Jones", | ||
firstName: "Bob", | ||
lastName: "Jones", | ||
role: "MUSICIAN", | ||
hashedPassword: await hashPassword("bobPassword"), | ||
sessions: { | ||
createMany: { | ||
data: [ | ||
{ | ||
id: "12", | ||
sessionId: "12", | ||
expiresAt: new Date( | ||
new Date().setFullYear(new Date().getFullYear() - 1), | ||
), | ||
}, | ||
{ | ||
id: "45", | ||
sessionId: "45", | ||
expiresAt: new Date( | ||
new Date().setFullYear(new Date().getFullYear() + 10), | ||
), | ||
|
@@ -92,7 +96,7 @@ async function main() { | |
update: { | ||
sessions: { | ||
update: { | ||
where: { id: "78" }, | ||
where: { sessionId: "78" }, | ||
data: { | ||
expiresAt: new Date( | ||
new Date().setFullYear(new Date().getFullYear() - 1), | ||
|
@@ -102,13 +106,15 @@ async function main() { | |
}, | ||
}, | ||
create: { | ||
id: "56", | ||
userId: "56", | ||
email: "[email protected]", | ||
name: "Eve Smith", | ||
firstName: "Eve", | ||
lastName: "Brown", | ||
role: "MEDIA_MAKER", | ||
hashedPassword: await hashPassword("evePassword"), | ||
sessions: { | ||
create: { | ||
id: "78", | ||
sessionId: "78", | ||
expiresAt: new Date( | ||
new Date().setFullYear(new Date().getFullYear() - 1), | ||
), | ||
|
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
Oops, something went wrong.