Hey everyone- Does anyone know how to change a mod...
# orm-help
s
Hey everyone- Does anyone know how to change a model name without having to drop the table? I'm migrating to next-auth 4 and they have a change in the schema where it removes
@@map(users)
from the
model User
which will change the database table from
users
to
User
. When I run the migration it is saying that it will drop the user's database which I don't want to do 🙂
prisma green 1
Answering my own question, you can make a custom migration by running
prisma migrate dev --create-only
To rename a table you need to add to the migration file:
Copy code
ALTER TABLE "users" RENAME TO "User";
ALTER TABLE "User" RENAME CONSTRAINT "users_pkey" TO "User_pkey";
for each table name you want to change. With that being said, next-auth sure doesn't make it easy to update their prisma connector to the latest version. There are also a number of fields in the
users
,
accounts
and
sessions
tables that you'll have to change the name of along with the table names themselves. I'll post a reply if I can figure out the specific prisma migration needed to make that work.
👍 1