Changing Enum types
Hello I have an Enum that I need to change. The enum was
and I need it to be
When I do
pnpm prisma db push
I get an error:
I also can't seed the database. How do I reset the database so I can change the Enum?1 Reply
You chose to compile with the bot. One moment while I piece together your answer…
This error occurs because you are removing the STRIPE value from the PaymentType enum, but there is still data in your database using that value. When Prisma tries to migrate, it cannot convert existing rows with STRIPE to the new enum, resulting in the error you see.
How to reset the database so you can change the Enum:
1. Delete or update rows using the old enum value:
Before running the migration, you need to remove or update all rows in your database that use the STRIPE value. You can do this manually with SQL, for example: Or, if you want to update them to the new value: Replace "YourTable" and "paymentType" with your actual table and column names. 2. Reset the database (development only):
If you are in development and can afford to lose all data, you can use: This will drop the database, reapply all migrations, and re-seed it. This is the easiest way to resolve enum change issues in development environments, as confirmed in several issues (see example). 3. Rerun your migration:
After cleaning up the data or resetting the database, run: or Note:
If you are in production, you must carefully migrate your data before removing enum values to avoid data loss and migration failures. Prisma currently does not handle renaming or removing enum values gracefully if existing data uses them (see related issues, <https://github.com/prisma/prisma/issues/7712). If you continue to have issues, ensure there are no default values or constraints referencing the old enum value before migra tion (see also). ✅ Great, thanks for letting us know that this solved your question!
Before running the migration, you need to remove or update all rows in your database that use the STRIPE value. You can do this manually with SQL, for example: Or, if you want to update them to the new value: Replace "YourTable" and "paymentType" with your actual table and column names. 2. Reset the database (development only):
If you are in development and can afford to lose all data, you can use: This will drop the database, reapply all migrations, and re-seed it. This is the easiest way to resolve enum change issues in development environments, as confirmed in several issues (see example). 3. Rerun your migration:
After cleaning up the data or resetting the database, run: or Note:
If you are in production, you must carefully migrate your data before removing enum values to avoid data loss and migration failures. Prisma currently does not handle renaming or removing enum values gracefully if existing data uses them (see related issues, <https://github.com/prisma/prisma/issues/7712). If you continue to have issues, ensure there are no default values or constraints referencing the old enum value before migra tion (see also). ✅ Great, thanks for letting us know that this solved your question!