add comments to the export script

This commit is contained in:
johnnyfish
2024-09-03 10:59:56 +03:00
committed by Guy Ben-Aharon
parent f61add50e9
commit d4f226e40a

View File

@@ -68,6 +68,18 @@ export const exportBaseSQL = (diagram: Diagram): string => {
sqlScript += '\n);\n\n';
// Add table comment
if (table.comments) {
sqlScript += `COMMENT ON TABLE ${table.name} IS '${table.comments}';\n`;
}
table.fields.forEach((field) => {
// Add column comment
if (field.comments) {
sqlScript += `COMMENT ON COLUMN ${table.name}.${field.name} IS '${field.comments}';\n`;
}
});
// Generate SQL for indexes
table.indexes.forEach((index) => {
const fieldNames = index.fieldIds