英文:
prisma how to disable not null
问题
Here is the translation of the code and question you provided:
我的模型如下
```js
model Trackings {
deliverStatus String @default("") @db.VarChar(255)
@@map(name: "trackings")
}
运行
npx run db push
我得到了这个SQL
```sql
`deliverStatus ` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
问题是SQL中出现了Not Null
,我不是有意这样做的。如何告诉Prisma不要这样做?
另外一个问题,我也不想要这个CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
,但是Prisma还是加了它,如何停止它添加?
<details>
<summary>英文:</summary>
my model is like this
```js
model Trackings {
deliverStatus String @default("") @db.VarChar(255)
@@map(name: "trackings")
}
run
npx run db push
I got this sql
`deliverStatus ` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
The problem is I got Not Null
in the sql, I didn't mean to do that. How to tell prisma not to do that ?
A side question, I didn't mean to have this one too CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
but prisma added it anyway, how to stop that?
答案1
得分: 1
model Trackings {
deliverStatus? String @default("") @db.VarChar(255)
@@map(name: "trackings")
}
英文:
I just need to do this, add the ?
model Trackings {
deliverStatus? String @default("") @db.VarChar(255)
@@map(name: "trackings")
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论