Function
hasColumn
(queryRunner: QueryRunner, tableName: string, columnName: string)
Source from the content-addressed store, hash-verified
| 1 | import { QueryRunner } from 'typeorm' |
| 2 | |
| 3 | export async function hasColumn(queryRunner: QueryRunner, tableName: string, columnName: string): Promise<boolean> { |
| 4 | const table = await queryRunner.getTable(tableName) |
| 5 | |
| 6 | if (!table) { |
| 7 | throw new Error(`Table ${tableName} not found`) |
| 8 | } |
| 9 | |
| 10 | const hasColumn = table.columns.some((column) => column.name === columnName) |
| 11 | |
| 12 | return hasColumn |
| 13 | } |
Tested by
no test coverage detected