drizzle-team / drizzle-team/drizzle-orm
[BUG]: drizzle-kit pull fails with column_unsupported_unique for unique indexes on text/mediumtext/longtext columns
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
1.0.0-rc.4
### What version of `drizzle-kit` are you using?
1.0.0-rc.4
### Other packages
_No response_
### Describe the Bug
**drizzle-kit version:** 1.0.0-rc.4
**Dialect:** MySQL (via bun driver)
**Bug:** When running drizzle-kit pull on a MySQL database that has unique indexes on text/mediumtext/longtext columns, pull fails with:
```
Failed to map the introspected schema
column_unsupported_unique (tablename); ...
```
The error originates from a hardcoded `resrtictedUniqueFor` array (this is a typo btw) in the MySQL introspection code path that lists "text", "tinytext", "mediumtext", "longtext" (and blob types) as types that cannot have unique indexes:
```
const resrtictedUniqueFor = [
'blob',
'tinyblob',
'mediumblob',
'longblob',
'text',
'tinytext',
'mediumtext',
'longtext',
];
```
**Problem:** MySQL **does** support unique indexes on TEXT/BLOB columns when a prefix length is specified (e.g., UNIQUE KEY prefix (prefix(255))).
**Drizzle-kit should either:**
- Allow these unique indexes and represent them in the schema (drizzle-orm's generated DDL would need to handle prefix lengths), or
- At minimum, emit a warning instead of a hard error that blocks the entire pull
The current behavior makes drizzle-kit pull unusable on any MySQL database that has unique indexes on text-type columns, which is a common pattern for columns like reset_token, prefix, code, key, etc.
**Workaround applied:** Emptying the resrtictedUniqueFor array allowed the pull to succeed.
Contributor guide
Research direction
Start in the MySQL introspection code path and inspect the misspelled resrtictedUniqueFor array and the column_unsupported_unique failure. Reproduce drizzle-kit pull with a unique prefix index on a TEXT or BLOB column, then determine whether the schema can represent the prefix length or whether the pull should warn without failing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, typescript
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100