[PR #4132] [MERGED] fix(cli): Incorrect drizzle schema gen #5207

Closed
opened 2026-03-13 12:14:08 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4132
Author: @ping-maxwell
Created: 8/21/2025
Status: Merged
Merged: 8/24/2025
Merged by: @himself65

Base: canaryHead: fix/drizzle-schema-gen/references-incorrect-model-name


📝 Commits (5)

  • 1eb2492 fix(cli): Incorrect drizzle schema gen
  • 6150737 chore: lint
  • c3b6b62 update: tests
  • 2c5d6d8 chore: lint
  • da7b7c4 Merge branch 'canary' into fix/drizzle-schema-gen/references-incorrect-model-name

📊 Changes

4 files changed (+40 additions, -15 deletions)

View changed files

📝 packages/cli/src/generators/drizzle.ts (+2 -1)
📝 packages/cli/test/__snapshots__/auth-schema-number-id.txt (+7 -7)
📝 packages/cli/test/__snapshots__/auth-schema.txt (+7 -7)
📝 packages/cli/test/generate.test.ts (+24 -0)

📄 Description

closes https://github.com/better-auth/better-auth/issues/2307


Summary by cubic

Fixes incorrect Drizzle schema generation for foreign key references. The generator now resolves the correct model name from the tables map, preventing broken .references() targets.

  • Bug Fixes
    • Use tables[ref.model]?.modelName || ref.model when building .references() so custom model names are respected.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/4132 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 8/21/2025 **Status:** ✅ Merged **Merged:** 8/24/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/drizzle-schema-gen/references-incorrect-model-name` --- ### 📝 Commits (5) - [`1eb2492`](https://github.com/better-auth/better-auth/commit/1eb249299beb7030feaede047a6ec53e5a4fc33a) fix(cli): Incorrect drizzle schema gen - [`6150737`](https://github.com/better-auth/better-auth/commit/6150737251728e770827e1e047d75e158c488312) chore: lint - [`c3b6b62`](https://github.com/better-auth/better-auth/commit/c3b6b6290220c76df9de8e58748e3e13735aa987) update: tests - [`2c5d6d8`](https://github.com/better-auth/better-auth/commit/2c5d6d8c189dde965a0cf2cfb821186c49b18c73) chore: lint - [`da7b7c4`](https://github.com/better-auth/better-auth/commit/da7b7c4b7ee2df1372644abcb0e75fc9a17eda63) Merge branch 'canary' into fix/drizzle-schema-gen/references-incorrect-model-name ### 📊 Changes **4 files changed** (+40 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `packages/cli/src/generators/drizzle.ts` (+2 -1) 📝 `packages/cli/test/__snapshots__/auth-schema-number-id.txt` (+7 -7) 📝 `packages/cli/test/__snapshots__/auth-schema.txt` (+7 -7) 📝 `packages/cli/test/generate.test.ts` (+24 -0) </details> ### 📄 Description closes https://github.com/better-auth/better-auth/issues/2307 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes incorrect Drizzle schema generation for foreign key references. The generator now resolves the correct model name from the tables map, preventing broken .references() targets. - **Bug Fixes** - Use tables[ref.model]?.modelName || ref.model when building .references() so custom model names are respected. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:14:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#5207