Skip to main content
Version: 4.5

Class: SchemaHelper#

knex.SchemaHelper

Constructors#

constructor#

+ new SchemaHelper(): SchemaHelper

Returns: SchemaHelper

Methods#

databaseExists#

databaseExists(connection: Connection, name: string): Promise<boolean>

Parameters:#

NameType
connectionConnection
namestring

Returns: Promise<boolean>

Defined in: packages/knex/src/schema/SchemaHelper.ts:182


finalizeTable#

finalizeTable(table: TableBuilder, charset: string, collate?: string): void

Parameters:#

NameType
tableTableBuilder
charsetstring
collate?string

Returns: void

Defined in: packages/knex/src/schema/SchemaHelper.ts:16


getColumns#

getColumns(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<any[]>

Parameters:#

NameType
connectionAbstractSqlConnection
tableNamestring
schemaName?string

Returns: Promise<any[]>

Defined in: packages/knex/src/schema/SchemaHelper.ts:93


getCreateDatabaseSQL#

getCreateDatabaseSQL(name: string): string

Parameters:#

NameType
namestring

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:158


getDatabaseExistsSQL#

getDatabaseExistsSQL(name: string): string

Parameters:#

NameType
namestring

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:166


getDatabaseNotExistsError#

getDatabaseNotExistsError(dbName: string): string

Parameters:#

NameType
dbNamestring

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:170


getDefaultEmptyString#

getDefaultEmptyString(): string

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:178


getDropDatabaseSQL#

getDropDatabaseSQL(name: string): string

Parameters:#

NameType
namestring

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:162


getEnumDefinitions#

getEnumDefinitions(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<Dictionary<any>>

Parameters:#

NameType
connectionAbstractSqlConnection
tableNamestring
schemaName?string

Returns: Promise<Dictionary<any>>

Defined in: packages/knex/src/schema/SchemaHelper.ts:81


getForeignKeys#

getForeignKeys(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<Dictionary<any>>

Parameters:#

NameType
connectionAbstractSqlConnection
tableNamestring
schemaName?string

Returns: Promise<Dictionary<any>>

Defined in: packages/knex/src/schema/SchemaHelper.ts:76


getForeignKeysSQL#

getForeignKeysSQL(tableName: string, schemaName?: string): string

Parameters:#

NameType
tableNamestring
schemaName?string

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:101


getIndexName#

getIndexName(tableName: string, columns: string[], type: index | unique | foreign): string

Returns the default name of index for the given columns

Parameters:#

NameType
tableNamestring
columnsstring[]
typeindex | unique | foreign

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:108


getIndexes#

getIndexes(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<Index[]>

Parameters:#

NameType
connectionAbstractSqlConnection
tableNamestring
schemaName?string

Returns: Promise<Index[]>

Defined in: packages/knex/src/schema/SchemaHelper.ts:97


getListTablesSQL#

getListTablesSQL(): string

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:85


getManagementDbName#

getManagementDbName(): string

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:174


getPrimaryKeys#

getPrimaryKeys(connection: AbstractSqlConnection, indexes: Index[], tableName: string, schemaName?: string): Promise<string[]>

Parameters:#

NameType
connectionAbstractSqlConnection
indexesIndex[]
tableNamestring
schemaName?string

Returns: Promise<string[]>

Defined in: packages/knex/src/schema/SchemaHelper.ts:72


getRenameColumnSQL#

getRenameColumnSQL(tableName: string, from: Column, to: EntityProperty<any>, idx?: number, quote?: string): string

Parameters:#

NameTypeDefault value
tableNamestring-
fromColumn-
toEntityProperty<any>-
idxnumber0
quotestring'"'

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:89


getSchemaBeginning#

getSchemaBeginning(charset: string): string

Parameters:#

NameType
charsetstring

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:8


getSchemaEnd#

getSchemaEnd(): string

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:12


getTypeDefinition#

getTypeDefinition(prop: EntityProperty<any>, types?: Dictionary<string[]>, lengths?: Dictionary<number>, allowZero?: boolean): string

Parameters:#

NameTypeDefault value
propEntityProperty<any>-
typesDictionary<string[]>-
lengthsDictionary<number>-
allowZerobooleanfalse

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:20


getTypeFromDefinition#

getTypeFromDefinition(type: string, defaultType: string, types?: Dictionary<string[]>): string

Parameters:#

NameType
typestring
defaultTypestring
types?Dictionary<string[]>

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:62


hasSameDefaultValue#

PrivatehasSameDefaultValue(info: Column, prop: EntityProperty<any>, defaultValues: Dictionary<string[]>): boolean

Parameters:#

NameType
infoColumn
propEntityProperty<any>
defaultValuesDictionary<string[]>

Returns: boolean

Defined in: packages/knex/src/schema/SchemaHelper.ts:214


hasSameEnumDefinition#

PrivatehasSameEnumDefinition(prop: EntityProperty<any>, column: Column): boolean

Parameters:#

NameType
propEntityProperty<any>
columnColumn

Returns: boolean

Defined in: packages/knex/src/schema/SchemaHelper.ts:251


hasSameIndex#

PrivatehasSameIndex(prop: EntityProperty<any>, column: Column): boolean

Parameters:#

NameType
propEntityProperty<any>
columnColumn

Returns: boolean

Defined in: packages/knex/src/schema/SchemaHelper.ts:241


hasSameType#

PrivatehasSameType(columnType: string, infoType: string, types: Dictionary<string[]>): boolean

Parameters:#

NameType
columnTypestring
infoTypestring
typesDictionary<string[]>

Returns: boolean

Defined in: packages/knex/src/schema/SchemaHelper.ts:195


indexForeignKeys#

indexForeignKeys(): boolean

Returns: boolean

Defined in: packages/knex/src/schema/SchemaHelper.ts:51


isImplicitIndex#

isImplicitIndex(name: string): boolean

Implicit indexes will be ignored when diffing

Parameters:#

NameType
namestring

Returns: boolean

Defined in: packages/knex/src/schema/SchemaHelper.ts:58


isSame#

isSame(prop: EntityProperty<any>, column: Column, idx?: number, types?: Dictionary<string[]>, defaultValues?: Dictionary<string[]>): IsSame

Parameters:#

NameTypeDefault value
propEntityProperty<any>-
columnColumn-
idxnumber0
typesDictionary<string[]>-
defaultValuesDictionary<string[]>-

Returns: IsSame

Defined in: packages/knex/src/schema/SchemaHelper.ts:36


mapForeignKeys#

mapForeignKeys(fks: any[]): Dictionary<any>

Parameters:#

NameType
fksany[]

Returns: Dictionary<any>

Defined in: packages/knex/src/schema/SchemaHelper.ts:116


normalizeDefaultValue#

normalizeDefaultValue(defaultValue: string, length: number, defaultValues?: Dictionary<string[]>): string | number

Parameters:#

NameType
defaultValuestring
lengthnumber
defaultValuesDictionary<string[]>

Returns: string | number

Defined in: packages/knex/src/schema/SchemaHelper.ts:147


processTypeWildCard#

PrivateprocessTypeWildCard(prop: EntityProperty<any>, lengths: Dictionary<number>, propType: string, allowZero: boolean, type: string): string

Parameters:#

NameType
propEntityProperty<any>
lengthsDictionary<number>
propTypestring
allowZeroboolean
typestring

Returns: string

Defined in: packages/knex/src/schema/SchemaHelper.ts:131


supportsColumnAlter#

supportsColumnAlter(): boolean

Returns: boolean

Defined in: packages/knex/src/schema/SchemaHelper.ts:143


supportsSchemaConstraints#

supportsSchemaConstraints(): boolean

Returns: boolean

Defined in: packages/knex/src/schema/SchemaHelper.ts:47

Last updated on by Renovate Bot