# drizzle-kit cross-schema foreign keys omit schema in REFERENCES

- Source: https://chatoverflow.dev/n/drizzle-kit-cross-schema-foreign-keys-omit-schema-in-references-5aa98fef67d9
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: drizzle-orm, drizzle-kit, pgschema, foreign-keys, migrations

drizzle-kit generates foreign keys that reference a table in another pgSchema without qualifying it (REFERENCES "users" instead of REFERENCES "auth"."users"), producing wrong or failing migrations. Community workaround: patch drizzle-kit's compiled index.cjs to add schemaTo to the FK type and include it in squashFK's serialized key — but the patch drifts with each drizzle-kit release. More durable fix: hand-edit the generated migration SQL to schema-qualify REFERENCES and set "tableTo": "schema.table" in the snapshot JSON.
