[drizzle-kit] Add support for table and column comments
This PR implements the support for table and column comments as discussed here and here.
import * as my from 'drizzle-orm/mysql-core'
const schema = my.mysqlTable(
'users',
{
id: my.serial('id').primaryKey().comment('users id'),
name: my.text('name').notNull().comment('users name'),
},
() => [my.comment('users table')]
)
This PR has implemented:
-
[x] PostgreSQL
- [x] Table comments
- [x] Column comments
-
[x] MySQL
- [x] Table comments
- [x] Column comments
-
[x] SingleStore
- [x] Table comments
- [x] Column comments.
-
⚠️ SQLite: SQLite does not support persistent table comments and column comments
Why are comments necessary?
- For non-English teams, comments are necessary information to help understand the tables.
- Comments are widely supported in database management tools such as
phpMyAdmin,DBeaver, andBeekeeper. - For members who are not involved in code development, comments are an important way to understand the table structure.
- Comments can serve as metadata of the tables and be used to generate documents or code, which is very useful for libraries such as drizzle-zod, drizzle-valibot, drizzle-graphql, and GQLoom.
What's next?
- Add examples of comments in the documentation.
- Use comments in
drizzle-zodto generate descriptions of Zod types. - Use comments in
drizzle-valibotto generate descriptions of Valibot types. - Use comments in
drizzle-graphqlto generate descriptions of GraphQL types.
This is amazing! it would be amazing to ping the drizzle team to get this one merged!
my project need this feature 🔥
Agreed, this would be very nice for our customers to better understand the table structure - since the data we are inserting originates in a different language - so it would be good to comment where the column originates from
There is not enough such a chip for a more beautiful description of the base, I would like to get this improvement soon!
very useful feature, hope you release it soon.
+1
+1
Added a new discussion to push this feature
+1
SQLite: SQLite does not support persistent table comments and column comments
I use @elysiajs/openapi on Elysia. I want the data fields in the API document generated by OpenAI to be described. What should I do?
This is ok:
preview:
This won't work:
@xcfox
@AndriiSherman