Migration ... failed to apply cleanly to the shadow database. The relation "..." already exists #21401
-
QuestionBug description
But first migration had created fine. The error occure when I add the Contacts model New modelmodel Contacts {
id String @id @default(uuid())
timeStamp DateTime @default(now())
imageBgLink String
imagePreviewLink String?
title String
shortDescription String?
description_1 String?
description_2 String?
description_3 String?
description_4 String?
phone String?
mobile String?
email String?
socialLink_1 String?
socialLink_2 String?
socialLink_3 String?
socialLink_4 String?
socialLink_5 String?
copyright String?
} How to reproduce (optional)Expected behavior (optional)I expected opportunity to create new tables in my database when some tables in db allready have filled without dropping all tables,migration adn create it again Information about Prisma Schema, Client Queries and Environment (optional)generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model PageContents {
id String @id @default(uuid())
timeStamp DateTime @default(now())
imageBgLink String
imagePreviewLink String?
galary_link_1 String?
galary_link_2 String?
galary_link_3 String?
galary_link_4 String?
title String
subTitle String
shortDescription String
description_1 String
description_2 String?
description_3 String?
description_4 String?
}
model UserProfile {
id String @id @unique
email String
timeStamp DateTime @default(now())
date_of_birth String
phone String
login_name String
first_name String
last_name String
country String
adress String
avatar String
avatarPreview String
type UserTypeStatus
}
model Basket {
id String @id @default(uuid())
timeStamp DateTime @default(now())
product_id String
count Int
user_id String
}
model Product {
id String @id @default(uuid())
timeStamp DateTime @default(now())
imageBgLink String
imagePreviewLink String?
galary_link_1 String
galary_link_2 String
galary_link_3 String
galary_link_4 String
likes Int
dislikes Int
title String
subTitle String
category Category
price Decimal
productCode Decimal
discont Int
size String
weight Decimal
dimension String
dough String
calories Decimal
fat Decimal
arbohydrates Decimal
carbohydrates Decimal
shortDescription String
description_1 String
description_2 String?
description_3 String?
description_4 String?
}
enum UserTypeStatus {
Administrator
Moderator
User
}
enum Category {
Pizza
Burger
Salad
Soup
Sushi
Dessert
Drinks
First
Second
FastFood
Additionals
}` Prisma Client queriesCREATE TABLE "PageContents" (
"id" TEXT NOT NULL,
"timeStamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"imageBgLink" TEXT NOT NULL,
"imagePreviewLink" TEXT,
"galary_link_1" TEXT,
"galary_link_2" TEXT,
"galary_link_3" TEXT,
"galary_link_4" TEXT,
"title" TEXT NOT NULL,
"subTitle" TEXT NOT NULL,
"shortDescription" TEXT NOT NULL,
"description_1" TEXT NOT NULL,
"description_2" TEXT,
"description_3" TEXT,
"description_4" TEXT,
CONSTRAINT "PageContents_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "UserProfile" (
"id" TEXT NOT NULL,
"email" TEXT NOT NULL,
"timeStamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"date_of_birth" TEXT NOT NULL,
"phone" TEXT NOT NULL,
"login_name" TEXT NOT NULL,
"first_name" TEXT NOT NULL,
"last_name" TEXT NOT NULL,
"country" TEXT NOT NULL,
"adress" TEXT NOT NULL,
"avatar" TEXT NOT NULL,
"avatarPreview" TEXT NOT NULL,
"type" "UserTypeStatus" NOT NULL,
CONSTRAINT "UserProfile_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Basket" (
"id" TEXT NOT NULL,
"timeStamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"product_id" TEXT NOT NULL,
"count" INTEGER NOT NULL,
"user_id" TEXT NOT NULL,
CONSTRAINT "Basket_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Product" (
"id" TEXT NOT NULL,
"timeStamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"imageBgLink" TEXT NOT NULL,
"imagePreviewLink" TEXT,
"galary_link_1" TEXT NOT NULL,
"galary_link_2" TEXT NOT NULL,
"galary_link_3" TEXT NOT NULL,
"galary_link_4" TEXT NOT NULL,
"likes" INTEGER NOT NULL,
"dislikes" INTEGER NOT NULL,
"title" TEXT NOT NULL,
"subTitle" TEXT NOT NULL,
"category" "Category" NOT NULL,
"price" DECIMAL(65,30) NOT NULL,
"productCode" DECIMAL(65,30) NOT NULL,
"discont" INTEGER NOT NULL,
"size" TEXT NOT NULL,
"weight" DECIMAL(65,30) NOT NULL,
"dimension" TEXT NOT NULL,
"dough" TEXT NOT NULL,
"calories" DECIMAL(65,30) NOT NULL,
"fat" DECIMAL(65,30) NOT NULL,
"arbohydrates" DECIMAL(65,30) NOT NULL,
"carbohydrates" DECIMAL(65,30) NOT NULL,
"shortDescription" TEXT NOT NULL,
"description_1" TEXT NOT NULL,
"description_2" TEXT,
"description_3" TEXT,
"description_4" TEXT,
CONSTRAINT "Product_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "UserProfile_id_key" ON "UserProfile"("id");
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 17 replies
-
Hi @kravenhunter 👋 Thank you for raising this question. You are getting this error because the state of your local development database and Prisma schema are not in sync. You can try resetting the database using the If this answers your question, it would be great if you could mark this Discussion as answered to indicate that it has been resolved. Otherwise please let us know how else we can help you further or close the Discussion if it was resolved in some other way 🙏 |
Beta Was this translation helpful? Give feedback.
-
This error occurs when you delete you previous migration folders or some of the migration folders are missing. So you can manage the previous migration files and run |
Beta Was this translation helpful? Give feedback.
Can you start over, create a new database and delete the migration file to see if you can reproduce this again?