英文:
Prisma migrate not working due to schema not empty, but schema is empty (error P3005)
问题
我想测试一下 Prisma,因为我以前从未使用过它。
最初的迁移成功了,但我现在无法对模式进行更改。
我是否误解了 Prisma 迁移的工作原理?
我创建了一个简单的 Prisma 模式:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("POSTGRES_PRISMA_URL")
directUrl = env("POSTGRES_URL_NON_POOLING")
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String
}
然后运行了 prisma migrate dev --name init
,成功设置了我的数据库模式。
现在我对模式进行了更改,我向 User 模型添加了一个新的列:
model User {
id Int @id @default(autoincrement())
email String @unique
name String
username String
}
运行 prisma migrate dev --name add_username
失败,并显示以下错误:
Error: P3005
The database schema is not empty. Read more about how to baseline an existing production database: https://pris.ly/d/migrate-baseline
我做错了什么?
英文:
I wanted to test out prisma, as I have never used it before.
The inital migration was succesfull, but I am unable to make changes to the schema now.
Am I misunderstanding how prisma migrations are supposed to work?
What I did is create a simple prisma schema:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("POSTGRES_PRISMA_URL")
directUrl = env("POSTGRES_URL_NON_POOLING")
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String
}
And then ran prisma migrate dev --name init
, which successfully setup my DB schema.
Now I made changes to the schema, I added one new column to the User model:
model User {
id Int @id @default(autoincrement())
email String @unique
name String
username String
}
Running prisma migrate dev --name add_username
fails with the error:
Error: P3005
The database schema is not empty. Read more about how to baseline an existing production database: https://pris.ly/d/migrate-baseline
What am I doing wrong?
答案1
得分: 0
It seems it is an issue by the host (vercel in my case)
See this
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论