Skip to main content
Version: 6.3

PostgreSqlSchemaHelper

Hierarchy

Index

Constructors

constructor

Properties

staticreadonlyDEFAULT_VALUES

DEFAULT_VALUES: { ('now'::text)::timestamp(?) with time zone: string[]; ('now'::text)::timestamp(?) without time zone: string[]; current_timestamp(?): string[]; now(): string[]; null::character varying: string[]; null::timestamp with time zone: string[]; null::timestamp without time zone: string[] } = ...

Type declaration

  • ('now'::text)::timestamp(?) with time zone: string[]
  • ('now'::text)::timestamp(?) without time zone: string[]
  • current_timestamp(?): string[]
  • now(): string[]
  • null::character varying: string[]
  • null::timestamp with time zone: string[]
  • null::timestamp without time zone: string[]

Accessors

knex

  • get knex(): Knex<any, any[]>
  • Returns Knex<any, any[]>

options

  • get options(): { createForeignKeyConstraints?: boolean; disableForeignKeys?: boolean; ignoreSchema?: string[]; managementDbName?: string }
  • Returns { createForeignKeyConstraints?: boolean; disableForeignKeys?: boolean; ignoreSchema?: string[]; managementDbName?: string }

    • optionalcreateForeignKeyConstraints?: boolean
    • optionaldisableForeignKeys?: boolean
    • optionalignoreSchema?: string[]
    • optionalmanagementDbName?: string

Methods

configureColumn

  • configureColumn(column: Column, col: ColumnBuilder, knex: Knex<any, any[]>, changedProperties?: Set<string>): ColumnBuilder
  • Parameters

    • column: Column
    • col: ColumnBuilder
    • knex: Knex<any, any[]>
    • optionalchangedProperties: Set<string>

    Returns ColumnBuilder

configureColumnDefault

  • configureColumnDefault(column: Column, col: ColumnBuilder, knex: Knex<any, any[]>, changedProperties?: Set<string>): ColumnBuilder
  • Parameters

    • column: Column
    • col: ColumnBuilder
    • knex: Knex<any, any[]>
    • optionalchangedProperties: Set<string>

    Returns ColumnBuilder

createCheck

  • createCheck(table: CreateTableBuilder, check: CheckDef<unknown>): void
  • Parameters

    • table: CreateTableBuilder
    • check: CheckDef<unknown>

    Returns void

createForeignKey

  • createForeignKey(table: CreateTableBuilder, foreignKey: ForeignKey, schema?: string): void
  • Parameters

    • table: CreateTableBuilder
    • foreignKey: ForeignKey
    • optionalschema: string

    Returns void

createIndex

  • createIndex(table: CreateTableBuilder, index: IndexDef, tableDef: DatabaseTable, createPrimary?: boolean): void
  • Parameters

    • table: CreateTableBuilder
    • index: IndexDef
    • tableDef: DatabaseTable
    • createPrimary: boolean = false

    Returns void

createSchemaBuilder

  • createSchemaBuilder(schema?: string): SchemaBuilder
  • Parameters

    • optionalschema: string

    Returns SchemaBuilder

createTable

  • createTable(tableDef: DatabaseTable, alter?: boolean): SchemaBuilder
  • Parameters

    • tableDef: DatabaseTable
    • optionalalter: boolean

    Returns SchemaBuilder

createTableColumn

  • createTableColumn(table: TableBuilder, column: Column, fromTable: DatabaseTable, changedProperties?: Set<string>, alter?: boolean): undefined | ColumnBuilder
  • Parameters

    • table: TableBuilder
    • column: Column
    • fromTable: DatabaseTable
    • optionalchangedProperties: Set<string>
    • optionalalter: boolean

    Returns undefined | ColumnBuilder

databaseExists

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

    Returns Promise<boolean>

disableForeignKeysSQL

  • disableForeignKeysSQL(): string
  • Returns string

dump

  • dump(builder: string | SchemaBuilder, append: string): Promise<string>
  • Parameters

    • builder: string | SchemaBuilder
    • append: string

    Returns Promise<string>

enableForeignKeysSQL

  • enableForeignKeysSQL(): string
  • Returns string

finalizeTable

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

    • table: TableBuilder
    • charset: string
    • optionalcollate: string

    Returns void

getAllChecks

getAllColumns

getAllForeignKeys

getAllIndexes

getAlterColumnAutoincrement

  • getAlterColumnAutoincrement(tableName: string, column: Column, schemaName?: string): string
  • Parameters

    • tableName: string
    • column: Column
    • optionalschemaName: string

    Returns string

getAlterNativeEnumSQL

  • getAlterNativeEnumSQL(name: string, schema?: string, value?: string, items?: string[], oldItems?: string[]): string
  • Parameters

    • name: string
    • optionalschema: string
    • optionalvalue: string
    • optionalitems: string[]
    • optionaloldItems: string[]

    Returns string

optionalgetAlterTable

  • getAlterTable(changedTable: TableDifference, wrap?: boolean): Promise<string>
  • Parameters

    Returns Promise<string>

getChangeColumnCommentSQL

  • getChangeColumnCommentSQL(tableName: string, to: Column, schemaName?: string): string
  • Parameters

    • tableName: string
    • to: Column
    • optionalschemaName: string

    Returns string

getChecks

getColumns

  • Parameters

    Returns Promise<Column[]>

getCreateDatabaseSQL

  • getCreateDatabaseSQL(name: string): string
  • Parameters

    • name: string

    Returns string

getCreateIndexSQL

  • getCreateIndexSQL(tableName: string, index: IndexDef, partialExpression?: boolean): string
  • Parameters

    • tableName: string
    • index: IndexDef
    • partialExpression: boolean = false

    Returns string

getCreateNamespaceSQL

  • getCreateNamespaceSQL(name: string): string
  • Parameters

    • name: string

    Returns string

getCreateNativeEnumSQL

  • getCreateNativeEnumSQL(name: string, values: unknown[], schema?: string): string
  • Parameters

    • name: string
    • values: unknown[]
    • optionalschema: string

    Returns string

getDatabaseExistsSQL

  • getDatabaseExistsSQL(name: string): string
  • Parameters

    • name: string

    Returns string

getDatabaseNotExistsError

  • getDatabaseNotExistsError(dbName: string): string
  • Parameters

    • dbName: string

    Returns string

getDefaultEmptyString

  • getDefaultEmptyString(): string
  • Returns string

getDropColumnsSQL

  • getDropColumnsSQL(tableName: string, columns: Column[], schemaName?: string): string
  • Parameters

    • tableName: string
    • columns: Column[]
    • optionalschemaName: string

    Returns string

getDropDatabaseSQL

  • getDropDatabaseSQL(name: string): string
  • Parameters

    • name: string

    Returns string

getDropIndexSQL

  • getDropIndexSQL(tableName: string, index: IndexDef): string
  • Parameters

    Returns string

getDropNamespaceSQL

  • getDropNamespaceSQL(name: string): string
  • Parameters

    • name: string

    Returns string

getDropNativeEnumSQL

  • getDropNativeEnumSQL(name: string, schema?: string): string
  • Parameters

    • name: string
    • optionalschema: string

    Returns string

getEnumDefinitions

  • Parameters

    Returns Promise<Dictionary<string[]>>

getForeignKeys

  • Parameters

    Returns Promise<Dictionary>

getForeignKeysSQL

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

    • tableName: string
    • optionalschemaName: string

    Returns string

getIndexes

  • Parameters

    Returns Promise<IndexDef[]>

getListTablesSQL

  • getListTablesSQL(): string
  • Returns string

getManagementDbName

  • getManagementDbName(): string
  • Returns string

getNamespaces

getNativeEnumDefinitions

getPostAlterTable

  • Parameters

    Returns string

getPreAlterTable

  • Parameters

    Returns string

getPrimaryKeys

  • Parameters

    Returns Promise<string[]>

getReferencedTableName

  • getReferencedTableName(referencedTableName: string, schema?: string): string
  • Parameters

    • referencedTableName: string
    • optionalschema: string

    Returns string

getRenameColumnSQL

  • getRenameColumnSQL(tableName: string, oldColumnName: string, to: Column, schemaName?: string): string
  • Parameters

    • tableName: string
    • oldColumnName: string
    • to: Column
    • optionalschemaName: string

    Returns string

getRenameIndexSQL

  • getRenameIndexSQL(tableName: string, index: IndexDef, oldIndexName: string): string
  • Parameters

    • tableName: string
    • index: IndexDef
    • oldIndexName: string

    Returns string

getSchemaBeginning

  • getSchemaBeginning(charset: string): string
  • Parameters

    • charset: string

    Returns string

getSchemaEnd

  • getSchemaEnd(): string
  • Returns string

hasNonDefaultPrimaryKeyName

  • hasNonDefaultPrimaryKeyName(table: DatabaseTable): boolean
  • Parameters

    • table: DatabaseTable

    Returns boolean

inferLengthFromColumnType

  • inferLengthFromColumnType(type: string): undefined | number
  • Parameters

    • type: string

    Returns undefined | number

loadInformationSchema

  • loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[], schemas?: string[]): Promise<void>
  • Parameters

    Returns Promise<void>

mapForeignKeys

  • mapForeignKeys(fks: any[], tableName: string, schemaName?: string): Dictionary
  • Parameters

    • fks: any[]
    • tableName: string
    • optionalschemaName: string

    Returns Dictionary

normalizeDefaultValue

  • normalizeDefaultValue(defaultValue: string, length: number): string | number
  • Parameters

    • defaultValue: string
    • length: number

    Returns string | number

pushTableQuery

  • pushTableQuery(table: TableBuilder, expression: string, grouping?: string): void
  • Uses raw method injected in AbstractSqlConnection to allow adding custom queries inside alter statements.


    Parameters

    • table: TableBuilder
    • expression: string
    • grouping: string = 'alterTable'

    Returns void

splitTableName

  • splitTableName(name: string): [undefined | string, string]
  • Parameters

    • name: string

    Returns [undefined | string, string]

supportsSchemaConstraints

  • supportsSchemaConstraints(): boolean
  • Returns boolean