Upgrade to v4 — Is the SQL script to migrate the database needed? #3631
-
Question 💬Hi, After upgrading As my database is already in production, and Thanks! How to reproduce ☕️Migrate from next-auth v3 to v4 Try to login You get an error
Contributing 🙌🏽Yes, I am willing to help answer this question in a PR |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
This is a pretty serious issue. There is no way to safely upgrade to V4 if you were using the Prisma adapter. |
Beta Was this translation helpful? Give feedback.
-
@ThePaulMcBride, agreed this is a total showstopper for anyone with an existing deployment. I ran into this same problem too. What I've figured out so far is that you can start by removing the Delete everything in the migration and add:
This will allow you to change all of your table names from I then made the necessary changes to the prisma.schema file and ran a second
So I think the task is to figure out which of these fields can be changed from the old name to the new name. Does anyone know if I could possibly just drop the I'll report back if I can build out the rest of the commands you need to add to make this work but if anyone else knows please post a response. |
Beta Was this translation helpful? Give feedback.
-
As a followup, I was able to get my migration to work and I'll post my steps below. Your results might vary of course, but you can try backing up your database locally and trying it to see if it works seamlessly.
Now you can actually run Hope that helps! Please let me know if you run into issues or if there are changes that can be made to further battle test this. I had a pretty small database so there could be corner cases I didn't encounter, use at your own risk. |
Beta Was this translation helpful? Give feedback.
-
We have recently added a Database migration guide to the v3 -> v4 docs here: https://next-auth.js.org/getting-started/upgrade-v4#database-migration |
Beta Was this translation helpful? Give feedback.
We have recently added a Database migration guide to the v3 -> v4 docs here:
https://next-auth.js.org/getting-started/upgrade-v4#database-migration