upgrade cli does not distinguish that a field is ENUM and not a MEDIUMTEXT
Hello,
Our datamodel has a lot of ENUM type fields, some the cli were able to identify as such, but the rest were identified as MEDIUMTEXT.
Manually changing the SQL queries to the correct format, followed by introspection again did not remove the suggestion; it actually still showed that fields with MEDIUMTEXT type needed a default value, although I had already taken care of that.
please update on this issue still I have facing this issue.
Can you show an example of a Prisma 1 schema and the corresponding SQL schema that has this problem?
Thanks for a prompt response. please find here Prisma 1 schema
type User {
id: ID! @unique
email: String
userStatus: UserStatus @default(value: "PENDING")
userStatusUpdatedAt: DateTime
}
enum UserStatus {
APPROVED
BLOCKED
ARCHIVED
REJECTED
PENDING
REVOKED
}
As you can see here userStatus in User is enum.
So Prisma upgrade CLI given SQL statement for making PRISMA 2 compatible is,
ALTER TABLE `User` CHANGE `userStatus` `userStatus` ENUM('APPROVED', 'BLOCKED', 'ARCHIVED', 'REJECTED', 'PENDING', 'REVOKED') ;
ALTER TABLE `User` CHANGE `userStatus` `userStatus` MEDIUMTEXT DEFAULT 'PENDING';
So if we run the above script in a database then it will again convert this field into MEDIUMTEXT from ENUM. so ideal script for these changes should be this,
ALTER TABLE `User` CHANGE `userStatus` `userStatus` ENUM('APPROVED', 'BLOCKED', 'ARCHIVED', 'REJECTED', 'PENDING', 'REVOKED') DEFAULT 'PENDING' ;
also one more point for MySQL 5.7 version below script showing error BLOB, TEXT, GEOMETRY or JSON column 'userStatus' can't have a default value, due to TEXT type column does not support default value in 5.7 version MySQL.
ALTER TABLE `User` CHANGE `userStatus` `userStatus` MEDIUMTEXT DEFAULT 'PENDING';
also, MySQL version 8.0 also has not run the above script we need to slightly modify the above script in order to run in the database, here's updated script,
ALTER TABLE `User` CHANGE `userStatus` `userStatus` MEDIUMTEXT DEFAULT ('PENDING');
What does the Prima 1 created SQL look like before you use the upgrade CLI at all?