node.jsprismaprisma2

why migration is required during editing enum in prisma schema


enum OrderStatus {
    paymentDone
    OrderCreated
    OrderConfirmed
}

iam using prima postgres db if you add an extra literal orderCancelled in prisma schema it is asking for creating a new migration , why it behaves like this ?


Solution

  • This is the expected behaviour. Initially when the enum had 3 values, this migration script would have been executed.

    CREATE TYPE "OrderStatus" AS ENUM ('paymentDone', 'OrderCreated', 'OrderConfirmed');
    

    When you are adding a new enum OrderCancelled, the OrderStatus type needs to be altered like this.

    ALTER TYPE "OrderStatus" ADD VALUE 'OrderCancelled';
    

    So Prisma Migrate initiating a new migration is the correct behavior.