Skip to content
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

Gde crud journey event step comment #8

Merged
merged 14 commits into from
May 23, 2024
9,687 changes: 2,880 additions & 6,807 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ CREATE TABLE "Event" (
"updatedAt" TIMESTAMP(3) NOT NULL,
"isPrivate" BOOLEAN NOT NULL DEFAULT false,
"accessCode" TEXT,
"startTime" TIMESTAMP(3) NOT NULL,
"endTime" TIMESTAMP(3) NOT NULL,
"startAt" TIMESTAMP(3) NOT NULL,
"endAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Event_pkey" PRIMARY KEY ("id")
);
Expand All @@ -59,7 +59,6 @@ CREATE TABLE "UserEvent" (
"id" SERIAL NOT NULL,
"userId" INTEGER NOT NULL,
"eventId" INTEGER NOT NULL,
"lastStepId" INTEGER,

CONSTRAINT "UserEvent_pkey" PRIMARY KEY ("id")
);
Expand Down Expand Up @@ -98,16 +97,29 @@ CREATE TABLE "Step" (
"pictureHint" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"coordinates" TEXT NOT NULL,
"address" TEXT NOT NULL,
"city" TEXT NOT NULL,
"postalCode" TEXT NOT NULL,
"country" TEXT NOT NULL,
"latitude" DOUBLE PRECISION NOT NULL,
"longitude" DOUBLE PRECISION NOT NULL,
"address" TEXT,
"city" TEXT,
"postalCode" TEXT,
"country" TEXT,
"stepNumber" INTEGER NOT NULL,

CONSTRAINT "Step_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "UserStep" (
"id" SERIAL NOT NULL,
"userId" INTEGER NOT NULL,
"stepId" INTEGER NOT NULL,
"startAt" TIMESTAMP(3) NOT NULL,
"endAt" TIMESTAMP(3) NOT NULL,
"duration" INTEGER NOT NULL,

CONSTRAINT "UserStep_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Comment" (
"id" SERIAL NOT NULL,
Expand All @@ -125,34 +137,37 @@ CREATE TABLE "Comment" (
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- AddForeignKey
ALTER TABLE "UserRole" ADD CONSTRAINT "UserRole_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "UserRole" ADD CONSTRAINT "UserRole_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "UserRole" ADD CONSTRAINT "UserRole_roleId_fkey" FOREIGN KEY ("roleId") REFERENCES "Role"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "UserRole" ADD CONSTRAINT "UserRole_roleId_fkey" FOREIGN KEY ("roleId") REFERENCES "Role"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Event" ADD CONSTRAINT "Event_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "Event" ADD CONSTRAINT "Event_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Event" ADD CONSTRAINT "Event_journeyId_fkey" FOREIGN KEY ("journeyId") REFERENCES "Journey"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "Event" ADD CONSTRAINT "Event_journeyId_fkey" FOREIGN KEY ("journeyId") REFERENCES "Journey"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "UserEvent" ADD CONSTRAINT "UserEvent_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "UserEvent" ADD CONSTRAINT "UserEvent_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "UserEvent" ADD CONSTRAINT "UserEvent_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "UserEvent" ADD CONSTRAINT "UserEvent_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "UserEvent" ADD CONSTRAINT "UserEvent_lastStepId_fkey" FOREIGN KEY ("lastStepId") REFERENCES "Step"("id") ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE "Journey" ADD CONSTRAINT "Journey_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Journey" ADD CONSTRAINT "Journey_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "Step" ADD CONSTRAINT "Step_journeyId_fkey" FOREIGN KEY ("journeyId") REFERENCES "Journey"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "UserStep" ADD CONSTRAINT "UserStep_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Step" ADD CONSTRAINT "Step_journeyId_fkey" FOREIGN KEY ("journeyId") REFERENCES "Journey"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "UserStep" ADD CONSTRAINT "UserStep_stepId_fkey" FOREIGN KEY ("stepId") REFERENCES "Step"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Comment" ADD CONSTRAINT "Comment_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "Comment" ADD CONSTRAINT "Comment_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Comment" ADD CONSTRAINT "Comment_journeyId_fkey" FOREIGN KEY ("journeyId") REFERENCES "Journey"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE "Comment" ADD CONSTRAINT "Comment_journeyId_fkey" FOREIGN KEY ("journeyId") REFERENCES "Journey"("id") ON DELETE CASCADE ON UPDATE CASCADE;
3 changes: 3 additions & 0 deletions prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
60 changes: 35 additions & 25 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ model User {
experience Int @default(0)
userRoles UserRole[] // liste des rôles de l'utilisateur
userEvents UserEvent[] // liste des events auxquels l'utilisateur participe
userSteps UserStep[] // liste des étapes réalisées par l'utilisateur
comments Comment[] // liste des commentaires créés par l'utilisateur
journey Journey[] // liste des parcours créés par l'utilisateur
events Event[] // liste des events créés par l'utilisateur
Expand All @@ -44,8 +45,8 @@ model UserRole {
id Int @id @default(autoincrement())
userId Int
roleId Int
user User @relation(fields: [userId], references: [id])
role Role @relation(fields: [roleId], references: [id])
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
role Role @relation(fields: [roleId], references: [id], onDelete: Cascade)
}

model Event {
Expand All @@ -61,21 +62,19 @@ model Event {
updatedAt DateTime @updatedAt
isPrivate Boolean @default(false)
accessCode String?
startTime DateTime
endTime DateTime
startAt DateTime
endAt DateTime
userEvents UserEvent[]
author User @relation(fields: [authorId], references: [id])
journey Journey @relation(fields: [journeyId], references: [id])
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
journey Journey @relation(fields: [journeyId], references: [id], onDelete: Cascade)
}

model UserEvent {
id Int @id @default(autoincrement())
userId Int
eventId Int
lastStepId Int?
user User @relation(fields: [userId], references: [id])
event Event @relation(fields: [eventId], references: [id])
lastStep Step? @relation(fields: [lastStepId], references: [id])
id Int @id @default(autoincrement())
userId Int
eventId Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
}

model Journey {
Expand All @@ -97,30 +96,41 @@ model Journey {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
steps Step[]
Comment Comment[]
comments Comment[]
author User @relation(fields: [authorId], references: [id])
events Event[]
}

model Step {
id Int @id @default(autoincrement())
id Int @id @default(autoincrement())
journeyId Int
puzzle String
answer String
hint String
picturePuzzle String?
pictureHint String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
latitude Float
longitude Float
address String
city String
postalCode String
country String
address String?
city String?
postalCode String?
country String?
stepNumber Int
journey Journey @relation(fields: [journeyId], references: [id])
userEvents UserEvent[]
journey Journey @relation(fields: [journeyId], references: [id], onDelete: Cascade)
userSteps UserStep[]
}

model UserStep {
id Int @id @default(autoincrement())
userId Int
stepId Int
startAt DateTime
endAt DateTime
duration Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
step Step @relation(fields: [stepId], references: [id], onDelete: Cascade)
}

model Comment {
Expand All @@ -131,6 +141,6 @@ model Comment {
journeyId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [authorId], references: [id])
journey Journey @relation(fields: [journeyId], references: [id])
user User @relation(fields: [authorId], references: [id], onDelete: Cascade)
journey Journey @relation(fields: [journeyId], references: [id], onDelete: Cascade)
}
Loading
Loading