import { underscoredIf } from 'sequelize/lib/utils' ; export function smartTags ( tags ) { return Object . entries ( tags ) . map ( ( [ k , v ] ) => `@${ k } ${ v }` ) . join ( '\n' ) ; } const underscored = ( input ) => underscoredIf ( input , true ) ; export function getFkConstraint ( tableName , foreignKey ) { return [ tableName , foreignKey , 'fkey' ] . map ( underscored ) . join ( '_' ) ; } export function getUniqConstraint ( tableName , field ) { return [ tableName , field , 'uindex' ] . map ( underscored ) . join ( '_' ) ; } export function commentConstraintQuery ( table , constraint , comment ) { return `COMMENT ON CONSTRAINT ${ constraint } ON ${ table } IS E'${ comment }'` ; } export function createUniqueIndexQuery ( schema , table , field ) { return `create unique index if not exists '${ getUniqConstraint ( table , field ) }' on '${ schema }.${ table }' (${ underscored ( field ) })` ; }