Feature request - Include comments in SQL export

Hi, I’ve just found dbdiagram, and so far I’m loving it. Nice work! :slight_smile:

Would it be possible to include the comments when exporting a diagram to SQL? It could work like this:

// this is just a comment
table foo { // this is a table comment
  id int [pk] // and this is a column comment
}

The exported SQL would be something like this for PostgreSQL:

-- this is just a comment
create table foo (id int primary key);
comment on table foo is 'this is a table comment';
comment on column foo.id is 'this is a column comment';

And like this for MySQL:

-- this is just a comment
create table foo (
  id int primary key comment="this is a column comment"
) comment="this is a table comment";

Or if you want to keep it simple, just export everything as -- code comments, it would still be useful.

Hi thanks for for suggestion! Actually we just released this (haven’t updated our docs with it). Can you try the following, and then hover through the price field.

Table products {
  id int [pk]
  name varchar
  merchant_id int [not null]
  price int [note: "This is how much being listed"]
  status varchar
  created_at varchar
}
1 Like

Awesome!!! It works great both in the diagram and in the exported SQL :smiley:

Is there something similar for tables?

1 Like

Thanks mate, not at the moment no. But will update you guys when it comes.

https://dbdiagram.noting.io/vpoh65/support-field-note

This appears now to be broken for PostgreSQL .

The Comment statement is completely missing from PostgreSQL Export of the following:

Table listing_revenue_data1 {
  id int [pk, increment]
  include_in_listing bit [note: "test"]
 }