Hey folks, I'm running into an issue with failed m...
# prisma-migrate
k
Hey folks, I'm running into an issue with failed migration. Getting the following error from my build logs
Copy code
10:22:13.228  	Error: P3009
10:22:13.228  	migrate found failed migrations in the target database, new migrations will not be applied. Read more about how to resolve migration issues in a production database: <https://pris.ly/d/migrate-resolve>
10:22:13.228  	The `20210702212552_add_unique_constraint_to_job` migration started at 2021-07-07 13:52:17.927259 UTC failed with the following logs:
10:22:13.245  	error Command failed with exit code 1.
And this is the migrate from the error above:
Copy code
/*
  Warnings:

  - A unique constraint covering the columns `[queueId]` on the table `Job` will be added. If there are existing duplicate values, this will fail.
  - Made the column `vendorResponded` on table `Job` required. This step will fail if there are existing NULL values in that column.
  - Made the column `status` on table `Job` required. This step will fail if there are existing NULL values in that column.

*/
-- AlterTable
ALTER TABLE "Job" ALTER COLUMN "vendorResponded" SET NOT NULL,
ALTER COLUMN "status" SET NOT NULL;

-- CreateIndex
CREATE UNIQUE INDEX "Job.queueId_unique" ON "Job"("queueId");
I'm assuming the issue is coming from added
REQUIRED
constraint to
vendorRespond
and
status
columns. I'm trying to following along this guide here to resolve the issue, I'm a bit confused on how to approach it. Where are you supposed to run this command in the guide? From your local machine or you need to ssh into the production machine to do so? Many thanks!
Copy code
prisma migrate resolve --rolled-back "20201127134938_added_bio_index"
I'm assuming you'll need to ssh into the production environment to run
prisma migrate resolve --rolled-back
. This might be out of scope here, but I'm currently using Vercel as the deployment platform. Does anyone know if it's possible to log onto vercel's prod env and run prisma migrate resolve?
j
The machine does not matter at all - it matters that the project you are in is connecting to the correct database really.
k
But how and where should I run
prisma migrate resolve --rolled-back
if there's a failed migration in prod?
j
Probably on a local checkout with the production credentials.
🙌 1
Production should never really break in the first place 😕 But if it does, this of course is an emergency that needs to be fixed.
If you can SSH into the machine, that might be a way of course.
k
This is probably bad 😅 but I ended up just deleting the failure log in the prisma_migrations table in prod. And then the new migrations were able to finish running
j
It certainly raises the question why this worked 🤷 But sometimes it is better not to ask to many questions... right? 😄
😆 1