FG
๐Ÿ’ป Software๐Ÿ—„๏ธ Databases

[BUG]: Cannot update SQLite database due to foreign key constraints.

Freshover 1 year ago
Mar 14, 20260 views
Confidence Score79%
79%

Problem

What version of `drizzle-orm` are you using? 0.29.3 What version of `drizzle-kit` are you using? 0.20.13 Describe the Bug I don't have a reproducible demo created, but after making the following change: and trying to run `pnpm drizzle-kit sqlite:push`, I initially got this error: [code block] When I run it again, it prompts me to confirm that I want to delete `__old_push_projects` [code block] and upon agreeing, I get the same error: [code block] (I updated my drizzle-kit to latest and it produced the same error) Expected behavior Drizzle-kit should update my database. I'm not sure what the best approaches to this would be, since SQLite's table alters are pretty limited in what they can do, but maybe we can do something similar to how the Knex ORM resolved a similar issue in #4155 where they disabled foreign key checks temporarily using `PRAGMA foreign_keys = ON/OFF;` and retroactively checking post-migration with `PRAGMA foreign_key_check;` (see 7. Making Other Kinds Of Table Schema Changes on the sqlite.org site) Environment & setup node v21.5.0 better-sqlite3 9.2.2 edit: just realized I probably should've opened this issue on drizzle-kit, not sure how to transfer issues on GitHub though.

Error Output

Error: FOREIGN KEY constraint failed

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
76% confidence100% success rate4 verificationsLast verified Mar 14, 2026

Solution: [BUG]: Cannot update SQLite database due to foreign key constraints.

Low Risk

Any updates on this issue? Still facing problems trying to migrate here.

76

Trust Score

4 verifications

100% success
  1. 1

    Any updates on this issue? Still facing problems trying to migrate here.

    Any updates on this issue? Still facing problems trying to migrate here.

Validation

Resolved in drizzle-team/drizzle-orm GitHub issue #1813. Community reactions: 6 upvotes.

Verification Summary

Worked: 4
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

drizzleormtypescriptbugdrizzle/kitdb/sqlitepriority