prisma 部署后,prisma 没有应用更改
Posted
技术标签:
【中文标题】prisma 部署后,prisma 没有应用更改【英文标题】:prisma isn't applying changes after prisma deploy 【发布时间】:2020-06-06 20:15:41 【问题描述】:我已经更新了我的数据模型中的一些类型,并且在运行$prisma deploy
时它显示已经进行了更改。然而,playground 并没有反映这一点,在再次运行 $prisma deploy
时,它会重新更新相同的更改。
我一次又一次地收到这条消息,让我相信我的更新没有保存。
datamodel.prisma
type User
id: ID! @id
name: String!
email: String! @unique
posts: [Post!]!
comments: [Comment!]!
type Post
id: ID! @id
title: String!
body: String!
published: Boolean!
author: User!
comments: [Comment!]!
type Comment
id: ID! @id
text: String!
author: User!
post: Post!
docker-compose.yml
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.34
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
# managementApiSecret: my-secret
databases:
default:
connector: postgres
host: ec2-34-192-30-15.compute-1.amazonaws.com
database: dcpap3nn15tguo
schema: public
user: qlhncorhibvkbb
password: 273ef84b6ff75904084504c354f92879a036c887dfa4f688cdfaaf12f4e6c30d
ssl: true
rawAccess: true
port: '5432'
migrations: true
棱镜.yml
endpoint: http://localhost:4466
datamodel: datamodel.prisma
以及每次运行时的终端消息$prisma deploy
Deploying service `default` to stage `default` to server `local` 6.4s
Changes:
User (Type)
~ Updated field `email`. It became unique.
+ Created field `posts` of type `[Post!]!`
+ Created field `comments` of type `[Comment!]!`
Post (Type)
+ Created type `Post`
+ Created field `id` of type `ID!`
+ Created field `title` of type `String!`
+ Created field `body` of type `String!`
+ Created field `published` of type `Boolean!`
+ Created field `author` of type `User!`
+ Created field `comments` of type `[Comment!]!`
Comment (Type)
+ Created type `Comment`
+ Created field `id` of type `ID!`
+ Created field `text` of type `String!`
+ Created field `author` of type `User!`
+ Created field `post` of type `Post!`
PostToUser (Relation)
+ Created an inline relation between `Post` and `User` in the column `author` of table `Post`
CommentToUser (Relation)
+ Created an inline relation between `Comment` and `User` in the column `author` of table `Comment`
CommentToPost (Relation)
+ Created an inline relation between `Comment` and `Post` in the column `post` of table `Comment`
Applying changes 23.6s
Your Prisma endpoint is live:
HTTP: http://localhost:4466
WS: ws://localhost:4466
You can view & edit your data here:
Prisma Admin: http://localhost:4466/_admin
【问题讨论】:
【参考方案1】:查看 pgAdmin 中的迁移表:
SELECT * FROM management."Migration"
ORDER BY "projectId" ASC, revision DESC
这可能是由于 postgre 引发的错误未显示在控制台的 prisma deploy
输出中。
对我来说,这是因为我将 User.email
设置为 @unique
,但已经有多个用户使用相同的电子邮件,奇怪的是它没有被捕获,之后 postgre 不再接受任何迁移。
我在这里报告了这个错误:https://github.com/prisma/prisma/issues/2675
【讨论】:
【参考方案2】:同样的问题已经有一段时间了。不知道是什么问题,但我设法绕过它
将
prisma.yml
中的棱镜端点从http://localhost:4466
更改为http://locolhost:4466/anylabel/default
然后运行prisma1 deploy
这会将您的应用部署到数据库上的新服务上。
然后您可以在http://locolhost:4466/anylabel/default
上查看新模型的更改
(希望对您有所帮助,但我想您可能已经找到了解决方案)
【讨论】:
【参考方案3】:使用应该可以工作的prisma1 deploy
【讨论】:
以上是关于prisma 部署后,prisma 没有应用更改的主要内容,如果未能解决你的问题,请参考以下文章
从数据库中删除所有表后,如何将 prisma 重新部署到数据库
Prisma 1 + MongoDB Atlas 部署到 Heroku 返回错误 404