Skip to main content
Version: Next

Class: SchemaGenerator

knex.SchemaGenerator

Constructors#

constructor#

new SchemaGenerator(em)

Parameters#

NameType
emEntityManager<AbstractSqlDriver<AbstractSqlConnection>>

Defined in#

packages/knex/src/schema/SchemaGenerator.ts:17

Methods#

createDatabase#

createDatabase(name): Promise<void>

creates new database and connects to it

Parameters#

NameType
namestring

Returns#

Promise<void>

Defined in#

packages/knex/src/schema/SchemaGenerator.ts:290


createSchema#

createSchema(options?): Promise<void>

Parameters#

NameType
options?Object
options.wrap?boolean

Returns#

Promise<void>

Defined in#

packages/knex/src/schema/SchemaGenerator.ts:30


dropDatabase#

dropDatabase(name): Promise<void>

Parameters#

NameType
namestring

Returns#

Promise<void>

Defined in#

packages/knex/src/schema/SchemaGenerator.ts:296


dropSchema#

dropSchema(options?): Promise<void>

Parameters#

NameType
optionsObject
options.dropDb?boolean
options.dropMigrationsTable?boolean
options.wrap?boolean

Returns#

Promise<void>

Defined in#

packages/knex/src/schema/SchemaGenerator.ts:72


ensureDatabase#

ensureDatabase(): Promise<void>

Returns#

Promise<void>

Defined in#

packages/knex/src/schema/SchemaGenerator.ts:36


execute#

execute(sql, options?): Promise<void>

Parameters#

NameType
sqlstring
optionsObject
options.wrap?boolean

Returns#

Promise<void>

Defined in#

packages/knex/src/schema/SchemaGenerator.ts:302


generate#

generate(): Promise<string>

Returns#

Promise<string>

Defined in#

packages/knex/src/schema/SchemaGenerator.ts:21


getCreateSchemaSQL#

getCreateSchemaSQL(options?): Promise<string>

Parameters#

NameType
optionsObject
options.wrap?boolean

Returns#

Promise<string>

Defined in#

packages/knex/src/schema/SchemaGenerator.ts:52


getDropSchemaSQL#

getDropSchemaSQL(options?): Promise<string>

Parameters#

NameType
optionsObject
options.dropMigrationsTable?boolean
options.wrap?boolean

Returns#

Promise<string>

Defined in#

packages/knex/src/schema/SchemaGenerator.ts:84


getTargetSchema#

getTargetSchema(): DatabaseSchema

Returns#

DatabaseSchema

Defined in#

packages/knex/src/schema/SchemaGenerator.ts:47


getUpdateSchemaSQL#

getUpdateSchemaSQL(options?): Promise<string>

Parameters#

NameType
optionsObject
options.dropTables?boolean
options.fromSchema?DatabaseSchema
options.safe?boolean
options.wrap?boolean

Returns#

Promise<string>

Defined in#

packages/knex/src/schema/SchemaGenerator.ts:105


updateSchema#

updateSchema(options?): Promise<void>

Parameters#

NameType
optionsObject
options.dropTables?boolean
options.fromSchema?DatabaseSchema
options.safe?boolean
options.wrap?boolean

Returns#

Promise<void>

Defined in#

packages/knex/src/schema/SchemaGenerator.ts:100