drizzle-team / drizzle-team/drizzle-orm

[FEATURE]: Custom Indexes and Tables that encapsulate their migration logic

Open
#3,871 3 comments 4 reactions 0 assignees View on GitHub
drizzle/kit enhancement
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Feature hasn't been suggested before.

- [X] I have verified this feature I'm about to request hasn't been suggested before.

### Describe the enhancement you want to request

As a user of Drizzle, I think it would be a valuable enhancement if the index functions—similar to how custom types work—could encapsulate their migration logic. This would make it easier to create and manage migrate-able indexes, particularly for database systems like Vitess, where specialized indexing strategies are required.

For example, Vitess uses unique patterns for managing indexes, which currently requires a lot of manual handling in migrations. If Drizzle provided a way to define indexes with both their type-safe logic and migration steps in one place, it would significantly streamline this process for developers.

Additionally, adding support for custom tables (e.g., Vitess Sequences) could open up even more flexibility. This would allow developers to define reusable, type-safe abstractions for tables that require special handling, while also tying them into the migration framework seamlessly.

This feature could have a broader impact by encouraging the community to contribute their own database-specific solutions, like Vitess-friendly custom indexes or table definitions. These contributions would not only help the community but could also serve as strong candidates for Drizzle’s first-party offerings, enriching the overall ecosystem.

In essence, encapsulating both runtime and migration logic for indexes and custom tables would make Drizzle significantly more powerful for handling advanced use cases while maintaining the elegance of type safety and simplicity it’s known for.

---

Here are some related feature requests for custom indexes showing the demand. However, this request extends the pattern into custom tables as well.

https://github.com/drizzle-team/drizzle-orm/issues/3695
https://github.com/drizzle-team/drizzle-orm/issues/3789
https://github.com/drizzle-team/drizzle-orm/pull/3790

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.