Skip to content

Commit

Permalink
refactor(prisma): change schema
Browse files Browse the repository at this point in the history
  • Loading branch information
oliveirabalsa committed Jul 13, 2023
1 parent 66f0347 commit 00835da
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 59 deletions.
37 changes: 19 additions & 18 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ model User {
events EventsOnUsers[]
temporaryCodes TemporaryCode[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
Event Event? @relation(fields: [eventId], references: [id])
eventId String?
notificationsData NotificationData[]
notifications Notification[]
writtenTestimonies Testimony[] @relation("WrittenTestimonies")
testimonies Testimony[] @relation("Testimonies")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
Event Event? @relation(fields: [eventId], references: [id])
eventId String?
notificationsData NotificationData[]
notifications Notification[]
writtenTestimonies Testimony[] @relation("WrittenTestimonies")
testimonies Testimony[] @relation("Testimonies")
@@map("users")
}

Expand Down Expand Up @@ -87,13 +87,14 @@ model Event {

model EventsOnUsers {
event Event @relation(fields: [eventId], references: [id])
eventId String
eventId String @map("event_id")
user User @relation(fields: [userId], references: [id])
userId String
userId String @map("user_id")
assignedAt DateTime @default(now())
assignedBy String
@@id([eventId, userId])
@@map("events_on_users")
}

model Skill {
Expand Down Expand Up @@ -128,17 +129,17 @@ model NotificationData {
notifications Notification[]
@@map("notifications_data")
}
}

model Testimony {
id String @id @default(uuid())
id String @id @default(uuid())
learnerId String
mentorId String
text String
learner User @relation("WrittenTestimonies", fields: [learnerId], references: [id])
mentor User @relation("Testimonies", fields: [mentorId], references: [id])
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
learner User @relation("WrittenTestimonies", fields: [learnerId], references: [id])
mentor User @relation("Testimonies", fields: [mentorId], references: [id])
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@map("testimonies")
}
49 changes: 8 additions & 41 deletions schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,6 @@ type Skill {
name: String!
}

type NotificationData {
id: ID!
title: String!
description: String!
imageUrl: String
notifierId: ID
updatedAt: DateTime!
createdAt: DateTime!
}

type Notification {
id: ID!
notificationDataId: ID!
userId: ID!
read: Boolean!
data: NotificationData!
}

type Testimony {
id: ID!
mentorId: String!
Expand Down Expand Up @@ -150,10 +132,7 @@ type Query {
skill(id: Int!): Skill!
findNotifications(userId: String): [Notification!]!
findOneNotification(id: String!): Notification
findTestimonies(
learnerId: String
mentorId: String
): [CreateTestimonyOutput!]!
findTestimonies(learnerId: String, mentorId: String): [CreateTestimonyOutput!]!
findOneTestimony(id: String!): [CreateTestimonyOutput!]!
}

Expand Down Expand Up @@ -195,22 +174,16 @@ type Mutation {
resetUserPassword(userInput: ResetPasswordInput!): Boolean!
sendResetPassword(email: String!): Boolean!
createAvailability(createAvailabilityInput: CreateAvailabilityInput!): User!
updateAvailability(
updateAvailabilityInput: UpdateAvailabilityInput!
): Availability!
updateAvailability(updateAvailabilityInput: UpdateAvailabilityInput!): Availability!
removeAvailability(id: Int!): Availability!
createEvent(createEventInput: CreateEventInput!): Event!
updateEvent(updateEventInput: UpdateEventInput!): Event!
removeEvent(id: Int!): Event!
createSkill(createSkillInput: CreateSkillInput!): Skill!
updateSkill(updateSkillInput: UpdateSkillInput!): Skill!
removeSkill(id: Int!): Skill!
createNotification(
createNotificationInput: CreateNotificationInput!
): NotificationData!
updateNotification(
updateNotificationInput: UpdateNotificationInput!
): NotificationData!
createNotification(createNotificationInput: CreateNotificationInput!): NotificationData!
updateNotification(updateNotificationInput: UpdateNotificationInput!): NotificationData!
markRead(id: String!): Notification!
removeNotification(id: ID!): Boolean!
createTestimony(createTestimonyInput: CreateTestimonyInput!): Testimony!
Expand Down Expand Up @@ -280,9 +253,7 @@ input SignInUserInput {
rememberMe: Boolean
}

"""
The `Upload` scalar type represents a file upload.
"""
"""The `Upload` scalar type represents a file upload."""
scalar Upload

input ResetPasswordInput {
Expand Down Expand Up @@ -330,16 +301,12 @@ input UpdateEventInput {
}

input CreateSkillInput {
"""
Example field (placeholder)
"""
"""Example field (placeholder)"""
exampleField: Int!
}

input UpdateSkillInput {
"""
Example field (placeholder)
"""
"""Example field (placeholder)"""
exampleField: Int
id: Int!
}
Expand Down Expand Up @@ -372,4 +339,4 @@ input UpdateTestimonyInput {
learnerId: String
text: String
id: String!
}
}

0 comments on commit 00835da

Please sign in to comment.