“prisma how to disable not null” 翻译成中文是:”Prisma 如何禁用非空”

huangapple go评论51阅读模式
英文:

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(&quot;&quot;) @db.VarChar(255)
    @@map(name: &quot;trackings&quot;)
}

run

 npx run db push

I got this sql

`deliverStatus ` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT &#39;&#39;,

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(&quot;&quot;) @db.VarChar(255)
    @@map(name: &quot;trackings&quot;)
}

huangapple
  • 本文由 发表于 2023年4月17日 15:50:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76032821.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定