Skip to content

Instantly share code, notes, and snippets.

@sebass-surfer
Created April 6, 2022 06:10
Show Gist options
  • Save sebass-surfer/3a300a0d50abdcdad9bffbe9a05084c2 to your computer and use it in GitHub Desktop.
Save sebass-surfer/3a300a0d50abdcdad9bffbe9a05084c2 to your computer and use it in GitHub Desktop.
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @default(autoincrement()) @id
createdAt DateTime @default(now())
email String @unique
name String
age Int
role Role @default(USER)
pages Page[]
profile Profile?
}
model Profile {
id Int @default(autoincrement()) @id
user User @relation(fields: [userId], references: [id])
userId Int @unique
username String
location Location @relation(fields: [userId], references: [id])
firstName String
lastName String
bio String
avatarImage String
socialLinks Json?
statusPublished Boolean
websiteLink String
ctaButton String
}
model Location {
id Int @default(autoincrement()) @id
city String
state String
published Boolean
}
model Page {
id Int @default(autoincrement()) @id
createdAt DateTime @default(now())
flightNumber Int
title String
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId Int
contentTiles ContentTile[] @relation(references: [id])
}
model FeaturedTile {
id Int @default(autoincrement()) @id
name String
page Page[] @relation(references: [id])
config Json?
}
model Card {
id Int @default(autoincrement()) @id
createdAt DateTime @default(now())
flightNumber Int
title String
published Boolean @default(false)
featuredTile FeaturedTile[] @relation(references: [id])
cardTypes CardType[] @relation(references: [id])
}
model CardType {
id Int @default(autoincrement()) @id
name String
cards Card[] @relation(references: [id])
}
model ContentTile {
id Int @default(autoincrement()) @id
name String
page Page[] @relation(references: [id])
config Json?
}
model Tag {
id Int @default(autoincrement()) @id
name String
contentTiles ContentTile[] @relation(references: [id])
}
enum Role {
USER
ADMIN
BUSINESS
}
Error: Schema parsing
error: Error parsing attribute "@relation": The given constraint name `Profile_userId_fkey` has to be unique in the following namespace: on model `Profile` for primary key, indexes, unique constraints and foreign keys. Please provide a different name using the `map` argument.
--> schema.prisma:23
|
22 | id Int @default(autoincrement()) @id
23 | user User @relation(fields: [userId], references: [id])
24 | userId Int @unique
|
error: Error parsing attribute "@relation": The given constraint name `Profile_userId_fkey` has to be unique in the following namespace: on model `Profile` for primary key, indexes, unique constraints and foreign keys. Please provide a different name using the `map` argument.
--> schema.prisma:26
|
25 | username String
26 | location Location @relation(fields: [userId], references: [id])
27 | firstName String
|
error: Error validating field `location` in model `Profile`: The relation field `location` on Model `Profile` is missing an opposite relation field on the model `Location`. Either run `prisma format` or add it manually.
--> schema.prisma:26
|
25 | username String
26 | location Location @relation(fields: [userId], references: [id])
27 | firstName String
|
error: Error validating field `page` in model `FeaturedTile`: The relation field `page` on Model `FeaturedTile` is missing an opposite relation field on the model `Page`. Either run `prisma format` or add it manually.
--> schema.prisma:58
|
57 | name String
58 | page Page[] @relation(references: [id])
59 | config Json?
|
error: Error validating field `featuredTile` in model `Card`: The relation field `featuredTile` on Model `Card` is missing an opposite relation field on the model `FeaturedTile`. Either run `prisma format` or add it manually.
--> schema.prisma:68
|
67 | published Boolean @default(false)
68 | featuredTile FeaturedTile[] @relation(references: [id])
69 | cardTypes CardType[] @relation(references: [id])
|
error: Error validating field `contentTiles` in model `Tag`: The relation field `contentTiles` on Model `Tag` is missing an opposite relation field on the model `ContentTile`. Either run `prisma format` or add it manually.
--> schema.prisma:89
|
88 | name String
89 | contentTiles ContentTile[] @relation(references: [id])
90 | }
|
Validation Error Count: 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment