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

[BUG]: drizzle-kit generates incorrect foreign key references to a table from a different schema when using pgSchema

Freshabout 2 years ago
Mar 14, 20260 views
Confidence Score80%
80%

Problem

What version of `drizzle-orm` are you using? 0.26.1 What version of `drizzle-kit` are you using? 0.18.1 Describe the Bug I have this file that has two schemas, `iam` and `chat`. The `iam` scheme has `users` table and `chat` schema has `chatRooms` table. That `chatRooms` table has a foreign key that references the primary key for `users`. [code block] Using `drizzle-kit generate:pg` generates the following sql: [code block] The foreign key references `"chat"."users"("id")` instead of `"iam"."users"("id")`. Expected behavior The migration file generated by `drizzle-kit` should correctly reference table and columns from another schema in foreign keys. Environment & setup Postgres Fedora Linux

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
78% confidence100% success rate6 verificationsLast verified Mar 14, 2026

Solution: [BUG]: drizzle-kit generates incorrect foreign key references to a table from a different schema when using pgSchema

Low Risk

Any update on this? It's a bit tedious to have to reapply the patch with every update.

78

Trust Score

6 verifications

100% success
  1. 1

    Any update on this? It's a bit tedious to have to reapply the patch with every u

    Any update on this? It's a bit tedious to have to reapply the patch with every update.

Validation

Resolved in drizzle-team/drizzle-orm GitHub issue #636. Community reactions: 14 upvotes.

Verification Summary

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

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

drizzleormtypescriptbugdrizzle/kit