Bug: Migrations not compatible with D1 #24208
Labels
bug/2-confirmed
Bug has been reproduced and confirmed.
kind/bug
A reported bug.
team/schema
Issue for team Schema.
topic: d1
Issues related to Cloudflare D1
topic: migrate
topic: @prisma/adapter-d1
Milestone
Bug description
Generated migrations for D1 (following this guide) are not compatible with D1. When changing a table with relations, foreign keys are disabled and re-enabled with
PRAGMA foreign_keys=OFF;
andPRAGMA foreign_keys=ON;
.However, D1 seems to need
PRAMGA defer_foreign_keys=ON;
andPRAGMA defer_foreign_keys=OFF;
(also notice the swappedON
andOFF
).When applied, the migration fails with
✘ [ERROR] FOREIGN KEY constraint failed
.How to reproduce
Minimal reproduction: https://github.com/hrueger/prisma-24208
Expected behavior
Migrations are generated with
PRAGMA defer_foreign_keys
instead so that the migration can be applied.Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: