-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
prisma/prisma-engines
#4996Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.domain/schemaIssue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc.Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc.kind/bugA reported bug.A reported bug.topic: broken migrationstopic: migratetopic: postgresqltopic: prisma migrate devCLI: prisma migrate devCLI: prisma migrate dev
Description
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
5.14.0
Minding000
Metadata
Metadata
Assignees
Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.domain/schemaIssue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc.Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc.kind/bugA reported bug.A reported bug.topic: broken migrationstopic: migratetopic: postgresqltopic: prisma migrate devCLI: prisma migrate devCLI: prisma migrate dev