Skip to main content
Version: 5.2

SchemaGenerator

Should be renamed to SqlSchemaGenerator in v6

Hierarchy

Index

Constructors

constructor

Methods

clearDatabase

  • clearDatabase(options?: { schema?: string; truncate?: boolean }): Promise<void>
  • Parameters

    • optionaloptions: { schema?: string; truncate?: boolean }

    Returns Promise<void>

createDatabase

  • createDatabase(name: string): Promise<void>
  • creates new database and connects to it


    Parameters

    • name: string

    Returns Promise<void>

createSchema

  • createSchema(options?: { schema?: string; wrap?: boolean }): Promise<void>
  • Parameters

    • optionaloptions: { schema?: string; wrap?: boolean }

    Returns Promise<void>

diffToSQL

  • diffToSQL(schemaDiff: SchemaDifference, options: { dropTables?: boolean; safe?: boolean; schema?: string; wrap?: boolean }): Promise<string>
  • Parameters

    • schemaDiff: SchemaDifference
    • options: { dropTables?: boolean; safe?: boolean; schema?: string; wrap?: boolean }

    Returns Promise<string>

dropDatabase

  • dropDatabase(name: string): Promise<void>
  • Parameters

    • name: string

    Returns Promise<void>

dropSchema

  • dropSchema(options?: { dropDb?: boolean; dropMigrationsTable?: boolean; schema?: string; wrap?: boolean }): Promise<void>
  • Parameters

    • options: { dropDb?: boolean; dropMigrationsTable?: boolean; schema?: string; wrap?: boolean } = {}

    Returns Promise<void>

ensureDatabase

  • ensureDatabase(): Promise<boolean>
  • Returns true if the database was created.


    Returns Promise<boolean>

ensureIndexes

  • ensureIndexes(): Promise<void>
  • Returns Promise<void>

execute

  • execute(sql: string, options?: { wrap?: boolean }): Promise<void>
  • Parameters

    • sql: string
    • options: { wrap?: boolean } = {}

    Returns Promise<void>

generate

  • generate(): Promise<string>
  • Returns Promise<string>

getCreateSchemaSQL

  • getCreateSchemaSQL(options?: { schema?: string; wrap?: boolean }): Promise<string>
  • Parameters

    • options: { schema?: string; wrap?: boolean } = {}

    Returns Promise<string>

getDropSchemaSQL

  • getDropSchemaSQL(options?: { dropMigrationsTable?: boolean; schema?: string; wrap?: boolean }): Promise<string>
  • Parameters

    • options: { dropMigrationsTable?: boolean; schema?: string; wrap?: boolean } = {}

    Returns Promise<string>

getTargetSchema

  • getTargetSchema(schema?: string): DatabaseSchema
  • Parameters

    • optionalschema: string

    Returns DatabaseSchema

getUpdateSchemaMigrationSQL

  • getUpdateSchemaMigrationSQL(options?: { dropTables?: boolean; fromSchema?: DatabaseSchema; safe?: boolean; schema?: string; wrap?: boolean }): Promise<{ down: string; up: string }>
  • Parameters

    • options: { dropTables?: boolean; fromSchema?: DatabaseSchema; safe?: boolean; schema?: string; wrap?: boolean } = {}

    Returns Promise<{ down: string; up: string }>

getUpdateSchemaSQL

  • getUpdateSchemaSQL(options?: { dropTables?: boolean; fromSchema?: DatabaseSchema; safe?: boolean; schema?: string; wrap?: boolean }): Promise<string>
  • Parameters

    • options: { dropTables?: boolean; fromSchema?: DatabaseSchema; safe?: boolean; schema?: string; wrap?: boolean } = {}

    Returns Promise<string>

refreshDatabase

  • refreshDatabase(): Promise<void>
  • Returns Promise<void>

updateSchema

  • updateSchema(options?: { dropTables?: boolean; fromSchema?: DatabaseSchema; safe?: boolean; schema?: string; wrap?: boolean }): Promise<void>
  • Parameters

    • options: { dropTables?: boolean; fromSchema?: DatabaseSchema; safe?: boolean; schema?: string; wrap?: boolean } = {}

    Returns Promise<void>