[PR #4400] [MERGED] fix(db): special case schema generation ID #22262

Closed
opened 2026-04-15 20:55:15 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4400
Author: @himself65
Created: 9/3/2025
Status: Merged
Merged: 9/3/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/09/03/db-generate


📝 Commits (1)

  • 7d2dd84 fix(db): special case schema generation ID

📊 Changes

7 files changed (+641 additions, -1 deletions)

View changed files

📝 packages/cli/src/generators/drizzle.ts (+5 -1)
packages/cli/test/__snapshots__/auth-schema-mysql-passkey-number-id.txt (+84 -0)
packages/cli/test/__snapshots__/auth-schema-mysql-passkey.txt (+84 -0)
packages/cli/test/__snapshots__/auth-schema-pg-passkey.txt (+83 -0)
packages/cli/test/__snapshots__/auth-schema-sqlite-passkey-number-id.txt (+91 -0)
packages/cli/test/__snapshots__/auth-schema-sqlite-passkey.txt (+91 -0)
📝 packages/cli/test/generate-all-db.test.ts (+203 -0)

📄 Description

Fixes: https://github.com/better-auth/better-auth/issues/4368


Summary by cubic

Special-case snake_case conversion in the Drizzle schema generator to handle acronyms (ID, URL, API) correctly. This fixes wrong column names (e.g., credential_i_d -> credential_id) and ensures consistent output across MySQL, PostgreSQL, and SQLite, including numeric ID mode.

  • Bug Fixes
    • Treat consecutive capitals as one word when converting to snake_case, then lowercase.
    • Added passkey snapshots and tests for MySQL, PostgreSQL, and SQLite (with and without number IDs) to lock in correct column names.

🔄 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/4400 **Author:** [@himself65](https://github.com/himself65) **Created:** 9/3/2025 **Status:** ✅ Merged **Merged:** 9/3/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/09/03/db-generate` --- ### 📝 Commits (1) - [`7d2dd84`](https://github.com/better-auth/better-auth/commit/7d2dd84dfae3e1e7e3ad16d73d710b70d76dbe47) fix(db): special case schema generation `ID` ### 📊 Changes **7 files changed** (+641 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/cli/src/generators/drizzle.ts` (+5 -1) ➕ `packages/cli/test/__snapshots__/auth-schema-mysql-passkey-number-id.txt` (+84 -0) ➕ `packages/cli/test/__snapshots__/auth-schema-mysql-passkey.txt` (+84 -0) ➕ `packages/cli/test/__snapshots__/auth-schema-pg-passkey.txt` (+83 -0) ➕ `packages/cli/test/__snapshots__/auth-schema-sqlite-passkey-number-id.txt` (+91 -0) ➕ `packages/cli/test/__snapshots__/auth-schema-sqlite-passkey.txt` (+91 -0) 📝 `packages/cli/test/generate-all-db.test.ts` (+203 -0) </details> ### 📄 Description Fixes: https://github.com/better-auth/better-auth/issues/4368 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Special-case snake_case conversion in the Drizzle schema generator to handle acronyms (ID, URL, API) correctly. This fixes wrong column names (e.g., credential_i_d -> credential_id) and ensures consistent output across MySQL, PostgreSQL, and SQLite, including numeric ID mode. - **Bug Fixes** - Treat consecutive capitals as one word when converting to snake_case, then lowercase. - Added passkey snapshots and tests for MySQL, PostgreSQL, and SQLite (with and without number IDs) to lock in correct column names. <!-- 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-04-15 20:55:15 -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#22262