Do not validate `default` for `@db.MediumText` as it is not allowed in MySQL
See original GitHub issueProblem
If setting a default value on a field with @db.MediumText
(mysql) running migrate
after a format
and generate
errors with shadow db error and migration fail and then have to reset database and lose all the data and thinking/suggesting that prisma format
should catch this.
model Stuff {
id String @id
// creates unrecoverable migration issue - @db.MediumText @default("")
label String @db.MediumText @default("")
}
Running prisma generate
prisma format
all seems fine, then run prisma migrate
and explodes and have to accept nuke of the db and start over.
My current solution when i encounter unrecoverable migration errors or tokyo drift like this is to use mysql workbench export wizard to export each table in db, but this won’t be sustainable as # of tables increase / go to prod etc. Maybe there is a way to backup whole db and force a migration or such.
Suggested solution
prisma format
should strip @default("")
from any keys that are String @db.MediumText
Alternatives
tbd
Additional context
mysql 8.0 and node v14.15.3
“@prisma/client”: “^2.22.1”, “express”: “^4.17.1”, “typescript”: “^4.2.3”
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
I can reproduce this and I think we should disallow this in the schema level validator rather than stripping this in format. Marking this as a confirmed bug.
While migrate cannot persist the default value on the db level, the client will still be able to write the value to the database in cases where no value is provided in the query. Rejecting this via a validation would break this functionality.