Bug description
If you perform two different types of alteration on a table for instance renaming a constraint and altering the data type of a column then prisma migrate dev
will generate incorrect sql code.
How to reproduce
- Consider the following schema:
model Fruits {
id Int @id(map:"custom_name")
name String @db.VarChar
}
- edit it in this way :
model Fruits {
id Int @id()
name String
}
- run
prisma migrate dev
- you will get the following error
Database error code: 42601
Database error:
ERROR: syntax error at or near ","
This is because the generated sql will look like this:
ALTER TABLE "Fruits" RENAME CONSTRAINT "custom_name" TO "fruits_pkey",
ALTER COLUMN "name" SET DATA TYPE TEXT; -- this should be a separate ALTER TABLE statement --
Expected behavior
the generated sql should look like this :
ALTER TABLE "Fruits" RENAME CONSTRAINT "custom_name" TO "fruits_pkey";
ALTER TABLE "Fruits" ALTER COLUMN "name" SET DATA TYPE TEXT;
Prisma information
// Add your schema.prisma
// Add your code using Prisma Client
Environment & setup
- OS: macOS,
- Database: PostgreSQL
- Node.js version: v20.13.1
Prisma Version