[PR #28] [CLOSED] closes: #26 #11303

Closed
opened 2026-04-13 07:41:08 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/28
Author: @baraich
Created: 9/29/2024
Status: Closed

Base: mainHead: closes-#26


📝 Commits (1)

📊 Changes

1 file changed (+134 additions, -164 deletions)

View changed files

📝 packages/better-auth/src/cli/utils/get-migration.ts (+134 -164)

📄 Description

Changes

According to the requirements the following error occurred because MySQL can index only the first N chars of a BLOB or TEXT column. So The error mainly happens when there is a field/column type of TEXT or BLOB or those belong to TEXT or BLOB types such as TINYBLOB, MEDIUMBLOB, LONGBLOB, TINYTEXT, MEDIUMTEXT, and LONGTEXT that you try to make a primary key or index. With full BLOB or TEXT without the length value, MySQL is unable to guarantee the uniqueness of the column as it’s of variable and dynamic size. So, when using BLOB or TEXT types as an index, the value of N must be supplied so that MySQL can determine the key length. However, MySQL doesn’t support a key length limit on TEXT or BLOB. TEXT(88) simply won’t work.

A workaround, was conditionally rendering type in the schema generated. When the dbType is mysql then we set the type to VARCHAR(255) otherwise TEXT.

VARCHAR can accepts upto 256 characters.


🔄 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/28 **Author:** [@baraich](https://github.com/baraich) **Created:** 9/29/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `closes-#26` --- ### 📝 Commits (1) - [`b0def65`](https://github.com/better-auth/better-auth/commit/b0def65b54566cf337faed1b3c0e8f827df61667) closes: #26 ### 📊 Changes **1 file changed** (+134 additions, -164 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/cli/utils/get-migration.ts` (+134 -164) </details> ### 📄 Description ## Changes According to the requirements the following error occurred because MySQL can index only the first _N_ chars of a `BLOB` or `TEXT` column. So The error mainly happens when there is a field/column type of `TEXT` or `BLOB` or those belong to `TEXT` or `BLOB` types such as `TINYBLOB`, `MEDIUMBLOB`, `LONGBLOB`, `TINYTEXT`, `MEDIUMTEXT`, and `LONGTEXT` that you try to make a primary key or index. With full `BLOB` or `TEXT` without the length value, MySQL is unable to guarantee the uniqueness of the column as it’s of variable and dynamic size. So, when using `BLOB` or `TEXT` types as an index, the value of N must be supplied so that MySQL can determine the key length. However, MySQL doesn’t support a key length limit on `TEXT` or `BLOB`. `TEXT(88)` simply won’t work. A workaround, was conditionally rendering type in the schema generated. When the `dbType` is mysql then we set the type to `VARCHAR(255)` otherwise `TEXT`. > `VARCHAR` can accepts upto 256 characters. --- <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-13 07:41: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#11303