drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[FEATURE]: Support Comments for Column definitions and introspections

Open danicruz0415 opened this issue 1 year ago • 4 comments

Describe what you want

MySQL has a feature where you can add comments to the column definitions. This is useful when exploring the database from a Database manager as the comment adds information for what the column is for, if the name is not suffitiencly explicit.

image (screenshot of phpMyAdmin, a mySQL db manager as an example of how comments are displayed)

I think is a good feature as it allows the dabase to have better documentation. I imagine it as follows: The following code

export const User = mysqlTable("user", {
    id: int("id").primaryKey().autoincrement().notNull(),
    email: varchar("email", { length: 255 }).notNull().unique().comment("email of the user"), // comment
});

would generate the following table

CREATE TABLE `user` (
    `id` int AUTO_INCREMENT NOT NULL,
    `email` varchar(255) NOT NULL COMMENT 'email of the user', -- comment
    CONSTRAINT `user_id` PRIMARY KEY(`id`),
    CONSTRAINT `user_email_unique` UNIQUE(`email`)
);

To update a column, alter statements allow to add comments as described here. Also, for the introspect tool, current comments can be read as explained here.

PS: sorry if this was proposed before, I did not find any issue relating column comments Thanks!

danicruz0415 avatar Jan 27 '24 18:01 danicruz0415