( columnOptions: ModelAttributeColumnOptions, schema: string, withoutForeignKey: boolean )
| 70 | } |
| 71 | |
| 72 | export function formatAttributes( |
| 73 | columnOptions: ModelAttributeColumnOptions, |
| 74 | schema: string, |
| 75 | withoutForeignKey: boolean |
| 76 | ): string { |
| 77 | const type = formatDataType(columnOptions.type); |
| 78 | const allowNull = columnOptions.allowNull === false ? 'NOT NULL' : ''; |
| 79 | const unique = columnOptions.unique ? 'UNIQUE' : ''; |
| 80 | const autoIncrement = columnOptions.autoIncrement ? 'AUTO_INCREMENT' : ''; // PostgreSQL |
| 81 | |
| 82 | const references = formatReferences(columnOptions, schema); |
| 83 | |
| 84 | return `${type} ${allowNull} ${unique} ${autoIncrement} ${withoutForeignKey ? '' : references}`.trim(); |
| 85 | } |
| 86 | |
| 87 | // TODO this should be using TypeClass.types['dbType'] instead of TypeClass.key |
| 88 | const sequelizeToPostgresTypeMap = { |
no test coverage detected