P
Prisma5mo ago
uralsmh

prisma is generating some crappy migrations for no reason

Hey folks, Can someone guide me why prims is generating some crappy migrations for no reason? I mean why it deletes the constraint ActionDependencyList_pkey and add it again after?
-- AlterTable
ALTER TABLE "ActionDependencyList" DROP CONSTRAINT "ActionDependencyList_pkey", --->here
ADD COLUMN "filename" TEXT NOT NULL,
DROP COLUMN "actions",
ADD COLUMN "actions" TEXT[],
ADD CONSTRAINT "ActionDependencyList_pkey" PRIMARY KEY ("repository_id", "filename");

-- AlterTable
ALTER TABLE "DailyRunnerCost" RENAME CONSTRAINT "CostTable_pkey" TO "DailyRunnerCost_pkey";

-- AddForeignKey
ALTER TABLE "ActionDependencyList" ADD CONSTRAINT "ActionDependencyList_repository_id_fkey" FOREIGN KEY ("repository_id") REFERENCES "Repository"("repository_id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AlterTable
ALTER TABLE "ActionDependencyList" DROP CONSTRAINT "ActionDependencyList_pkey", --->here
ADD COLUMN "filename" TEXT NOT NULL,
DROP COLUMN "actions",
ADD COLUMN "actions" TEXT[],
ADD CONSTRAINT "ActionDependencyList_pkey" PRIMARY KEY ("repository_id", "filename");

-- AlterTable
ALTER TABLE "DailyRunnerCost" RENAME CONSTRAINT "CostTable_pkey" TO "DailyRunnerCost_pkey";

-- AddForeignKey
ALTER TABLE "ActionDependencyList" ADD CONSTRAINT "ActionDependencyList_repository_id_fkey" FOREIGN KEY ("repository_id") REFERENCES "Repository"("repository_id") ON DELETE RESTRICT ON UPDATE CASCADE;
1 Reply
uralsmh
uralsmh5mo ago
Applying migration `20240618103051_action_dependency`
Error: P3018

A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve

Migration name: 20240618103051_action_dependency

Database error code: 42704

Database error:
ERROR: constraint "ActionDependencyList_pkey" of relation "ActionDependencyList" does not exist

DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42704), message: "constraint \"ActionDependencyList_pkey\" of relation \"ActionDependencyList\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("tablecmds.c"), line: Some(12038), routine: Some("ATExecDropConstraint") }
Applying migration `20240618103051_action_dependency`
Error: P3018

A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve

Migration name: 20240618103051_action_dependency

Database error code: 42704

Database error:
ERROR: constraint "ActionDependencyList_pkey" of relation "ActionDependencyList" does not exist

DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42704), message: "constraint \"ActionDependencyList_pkey\" of relation \"ActionDependencyList\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("tablecmds.c"), line: Some(12038), routine: Some("ATExecDropConstraint") }
I could not able to fix above error without modifying the script with below..
ALTER TABLE "ActionDependencyList" ADD COLUMN "filename" TEXT NOT NULL,
DROP COLUMN if exists "actions",
ALTER TABLE "ActionDependencyList" ADD COLUMN "filename" TEXT NOT NULL,
DROP COLUMN if exists "actions",
Want results from more Discord servers?
Add your server