pg-to-dbml
Version:
CLI tool to scan your postgres database, and output DBML.
13 lines (9 loc) • 524 B
JavaScript
const getColumnType = require('./getColumnType');
const getColumnSettings = require('./getColumnSettings');
module.exports = function getColumnDefinition(col, primaryKeys) {
const { character_maximum_length: charMaxLength, column_name: columnName } = col;
const dataType = getColumnType(col);
const characterMaxLength = charMaxLength ? `(${charMaxLength})` : ' ';
const columnSettings = getColumnSettings({ ...col, dataType });
return `\t"${columnName}" ${dataType}${characterMaxLength} ${columnSettings} `;
};