diff --git a/lib/dialects/mssql.ts b/lib/dialects/mssql.ts index 1db47b7..4db3305 100644 --- a/lib/dialects/mssql.ts +++ b/lib/dialects/mssql.ts @@ -342,6 +342,17 @@ export default class MSSQL implements SchemaInspector { return columnName as string; } + /** + * Get the primarys key column for the given table + */ + async primarys(table: string) { + + const results = await this.knex.raw("EXEC sp_pkeys ?",[table]) + + const columnName = results.length > 0 ? results : null; + return columnName as object; + } + // Foreign Keys // =============================================================================================== diff --git a/lib/types/schema-inspector.ts b/lib/types/schema-inspector.ts index f754eb1..2856d4f 100644 --- a/lib/types/schema-inspector.ts +++ b/lib/types/schema-inspector.ts @@ -21,6 +21,7 @@ export interface SchemaInspector { hasColumn(table: string, column: string): Promise; primary(table: string): Promise; + primarys(table: string): Promise; foreignKeys(table?: string): Promise;