Nimish Gupta
07/06/2021, 6:16 PMenum Position {
First
Second
Last
}
model Test {
id String @id @default(uuid())
name String @unique
positions Position[]
// common fields
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
@@map("test")
}
Now I am removing one value (Last) from enum Position
. So after removing I ran this command:
prisma generate --schema=./schema.prisma && prisma migrate dev --schema=./schema.prisma
Above command created a new migration file like this
/*
Warnings:
- The values [Last] on the enum `Position` will be removed. If these variants are still used in the database, this will fail.
*/
-- AlterEnum
BEGIN;
CREATE TYPE "Position_new" AS ENUM ('First', 'Second');
ALTER TABLE "test" ALTER COLUMN "positions" TYPE "Position_new" USING ("positions"::text::"Position_new");
ALTER TYPE "Position" RENAME TO "Position_old";
ALTER TYPE "Position_new" RENAME TO "Position";
DROP TYPE "Position_old";
COMMIT;
Now if I rerun prisma migrate dev --schema=./schema.prisma
, it should not do any change, because I haven't changed any thing and all the migrations should be completed with above migration file. But it is again asking for a new migration name and when I entered some name for migration it errors by this. Also it created one more migration file
/*
Warnings:
- Changed the column `positions` on the `test` table from a scalar field to a list field. If there are non-null values in that column, this step will fail.
*/
-- AlterTable
ALTER TABLE "test" ALTER COLUMN "positions" SET DATA TYPE "Position"[];
Here I couldn't understand why it is again asking for a new migration and even though we are giving it name it is throwing error.
Prisma version - 2.26.0janpio
Nimish Gupta
07/07/2021, 5:04 AMNimish Gupta
07/07/2021, 9:48 AMjanpio