Skip to main content
Version: 7.1

PgliteSchemaHelper

PGlite is a single-database engine — there is no management catalog and no CREATE DATABASE. Override the relevant lifecycle hooks to no-ops.

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

Properties

staticreadonlyinheritedDEFAULT_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

inheritedoptions

  • get options(): { createForeignKeyConstraints?: boolean; defaultDeleteRule?: cascade | no action | set null | set default | restrict; defaultUpdateRule?: cascade | no action | set null | set default | restrict; disableForeignKeys?: boolean; disableForeignKeysForClear?: boolean; ignoreRoutines?: boolean; ignoreSchema?: string[]; ignoreTriggers?: boolean; managementDbName?: string; skipColumns?: Dictionary<(string | RegExp)[]>; skipTables?: (string | RegExp)[]; skipViews?: (string | RegExp)[]; tableSpace?: string }
  • Returns { createForeignKeyConstraints?: boolean; defaultDeleteRule?: cascade | no action | set null | set default | restrict; defaultUpdateRule?: cascade | no action | set null | set default | restrict; disableForeignKeys?: boolean; disableForeignKeysForClear?: boolean; ignoreRoutines?: boolean; ignoreSchema?: string[]; ignoreTriggers?: boolean; managementDbName?: string; skipColumns?: Dictionary<(string | RegExp)[]>; skipTables?: (string | RegExp)[]; skipViews?: (string | RegExp)[]; tableSpace?: string }

    • optionalcreateForeignKeyConstraints?: boolean

      Generate foreign key constraints.

    • optionaldefaultDeleteRule?: cascade | no action | set null | set default | restrict

      Default ON DELETE rule for foreign keys. When not set, no rule is emitted and the database uses its native default (NO ACTION/RESTRICT).

    • optionaldefaultUpdateRule?: cascade | no action | set null | set default | restrict

      Default ON UPDATE rule for foreign keys. When not set, no rule is emitted and the database uses its native default (NO ACTION/RESTRICT).

    • optionaldisableForeignKeys?: boolean

      Try to disable foreign key checks during schema operations.

    • optionaldisableForeignKeysForClear?: boolean

      Try to disable foreign key checks during schema.clear(). Enabled by default for MySQL/MariaDB.

    • optionalignoreRoutines?: boolean

      Leave database stored routines (functions/procedures) unmanaged. New routines are still created, but existing routines are never dropped or altered based on the entity metadata — use this to safely adopt routine support without having pre-existing, hand-written routines removed when they are not mirrored in your metadata.

    • optionalignoreSchema?: string[]

      Schema names to ignore when comparing schemas.

    • optionalignoreTriggers?: boolean

      Leave database triggers unmanaged. Declared triggers are still created, but existing triggers are never dropped or altered based on the entity metadata — use this to protect hand-written triggers from being removed when they are not mirrored in the entity definitions.

    • optionalmanagementDbName?: string

      Database name to use for management operations (e.g., creating/dropping databases).

    • optionalskipColumns?: Dictionary<(string | RegExp)[]>

      Column names or patterns to skip during schema generation, keyed by table name.

    • optionalskipTables?: (string | RegExp)[]

      Table names or patterns to skip during schema generation.

    • optionalskipViews?: (string | RegExp)[]

      View names or patterns to skip during schema generation (e.g. PostGIS system views).

    • optionaltableSpace?: string

Methods

inheritedalterTable

  • alterTable(diff, safe): string[]
  • Returns SQL statements to apply a table difference (add/drop/alter columns, indexes, foreign keys).


    Parameters

    Returns string[]

inheritedalterTableColumn

  • alterTableColumn(column, table, changedProperties): string[]
  • Parameters

    • column: Column
    • table: DatabaseTable
    • changedProperties: Set<string>

    Returns string[]

inheritedalterTableComment

  • alterTableComment(table, comment): string
  • Parameters

    • table: DatabaseTable
    • optionalcomment: string

    Returns string

inheritedappend

  • append(array, sql, pad): void
  • Parameters

    • array: string[]
    • sql: string | string[]
    • pad: boolean = false

    Returns void

inheritedappendComments

  • appendComments(table): string[]
  • Parameters

    • table: DatabaseTable

    Returns string[]

inheritedcastColumn

  • castColumn(name, type): string
  • Parameters

    • name: string
    • type: string

    Returns string

inheritedcreateCheck

  • createCheck(table, check): string
  • Parameters

    • table: DatabaseTable
    • check: CheckDef<unknown>

    Returns string

inheritedcreateForeignKey

  • createForeignKey(table, foreignKey, alterTable, inline): string
  • Returns SQL to create a foreign key constraint on a table.


    Parameters

    • table: DatabaseTable
    • foreignKey: ForeignKey
    • alterTable: boolean = true
    • inline: boolean = false

    Returns string

inheritedcreateIndex

  • createIndex(index, table, createPrimary): string
  • Parameters

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

    Returns string

inheritedcreateMaterializedView

  • createMaterializedView(name, schema, definition, withData): string
  • Parameters

    • name: string
    • schema: undefined | string
    • definition: string
    • withData: boolean = true

    Returns string

inheritedcreateRoutine

  • createRoutine(routine): string
  • Default no-op so SQLite/libSQL silent-skip routine DDL; routine-capable dialects override.


    Parameters

    Returns string

inheritedcreateTable

  • createTable(table, alter): string[]
  • Returns SQL statements to create a table with all its columns, primary key, indexes, and checks.


    Parameters

    • table: DatabaseTable
    • optionalalter: boolean

    Returns string[]

inheritedcreateTableColumn

  • createTableColumn(column, table): undefined | string
  • Parameters

    • column: Column
    • table: DatabaseTable

    Returns undefined | string

inheritedcreateTrigger

  • createTrigger(table, trigger): string
  • Generates SQL to create a PostgreSQL trigger and its associated function.


    Parameters

    Returns string

inheritedcreateView

  • createView(name, schema, definition): string
  • Parameters

    • name: string
    • schema: undefined | string
    • definition: string

    Returns string

databaseExists

  • databaseExists(_connection, _name): Promise<boolean>
  • Parameters

    Returns Promise<boolean>

inheriteddisableForeignKeysSQL

  • disableForeignKeysSQL(): string
  • Returns SQL to disable foreign key checks.


    Returns string

inheriteddropConstraint

  • dropConstraint(table, name): string
  • Parameters

    • table: string
    • name: string

    Returns string

inheriteddropForeignKey

  • dropForeignKey(tableName, constraintName): string
  • Parameters

    • tableName: string
    • constraintName: string

    Returns string

inheriteddropIndex

  • dropIndex(table, index, oldIndexName): string
  • Parameters

    • table: string
    • index: IndexDef
    • oldIndexName: string = index.keyName

    Returns string

inheriteddropMaterializedViewIfExists

  • dropMaterializedViewIfExists(name, schema): string
  • Parameters

    • name: string
    • optionalschema: string

    Returns string

inheriteddropRoutine

  • dropRoutine(routine): string
  • Parameters

    Returns string

inheriteddropTableIfExists

  • dropTableIfExists(name, schema): string
  • Returns SQL to drop a table if it exists.


    Parameters

    • name: string
    • optionalschema: string

    Returns string

inheriteddropTrigger

  • dropTrigger(table, trigger): string
  • Generates SQL to drop a PostgreSQL trigger and its associated function.


    Parameters

    Returns string

inheriteddropViewIfExists

  • dropViewIfExists(name, schema): string
  • Parameters

    • name: string
    • optionalschema: string

    Returns string

inheritedenableForeignKeysSQL

  • enableForeignKeysSQL(): string
  • Returns SQL to re-enable foreign key checks.


    Returns string

inheritedfinalizeTable

  • finalizeTable(table, charset, collate): string
  • Parameters

    • table: DatabaseTable
    • charset: string
    • optionalcollate: string

    Returns string

inheritedgetAddColumnsSQL

  • getAddColumnsSQL(table, columns): string[]
  • Returns SQL to add columns to an existing table.


    Parameters

    • table: DatabaseTable
    • columns: Column[]

    Returns string[]

inheritedgetAllChecks

inheritedgetAllColumns

  • getAllColumns(connection, tablesBySchemas, nativeEnums, ctx): Promise<Dictionary<Column[]>>
  • Parameters

    • connection: AbstractSqlConnection
    • tablesBySchemas: Map<undefined | string, Table[]>
    • optionalnativeEnums: Dictionary<{ items: string[]; name: string; schema?: string }>
    • optionalctx: any

    Returns Promise<Dictionary<Column[]>>

inheritedgetAllForeignKeys

inheritedgetAllIndexes

inheritedgetAllRoutines

inheritedgetAllTables

  • getAllTables(connection, schemas, ctx): Promise<Table[]>
  • Retrieves all tables from the database.


    Parameters

    Returns Promise<Table[]>

inheritedgetAllTriggers

inheritedgetAlterNativeEnumSQL

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

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

    Returns string

inheritedgetChangeColumnCommentSQL

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

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

    Returns string

getCreateDatabaseSQL

  • getCreateDatabaseSQL(): string
  • Returns string

inheritedgetCreateIndexSQL

  • getCreateIndexSQL(tableName, index): string
  • Returns SQL to create an index on a table.


    Parameters

    Returns string

inheritedgetCreateNamespaceSQL

  • getCreateNamespaceSQL(name): string
  • Parameters

    • name: string

    Returns string

inheritedgetCreateNativeEnumSQL

  • getCreateNativeEnumSQL(name, values, schema): string
  • Parameters

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

    Returns string

inheritedgetDatabaseCollation

  • getDatabaseCollation(connection, ctx): Promise<undefined | string>
  • Resolves the real name of the implicit 'default' collation (the DB's datcollate), so the comparator can treat @Property({ collation: '<datcollate>' }) as equivalent to a column that introspects as using the default.


    Parameters

    Returns Promise<undefined | string>

inheritedgetDatabaseExistsSQL

  • getDatabaseExistsSQL(name): string
  • Parameters

    • name: string

    Returns string

inheritedgetDatabaseNotExistsError

  • getDatabaseNotExistsError(dbName): string
  • Parameters

    • dbName: string

    Returns string

inheritedgetDefaultEmptyString

  • getDefaultEmptyString(): string
  • Returns string

inheritedgetDropColumnsSQL

  • getDropColumnsSQL(tableName, columns, schemaName): string
  • Parameters

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

    Returns string

getDropDatabaseSQL

  • getDropDatabaseSQL(): string
  • Returns string

inheritedgetDropIndexSQL

  • getDropIndexSQL(tableName, index): string
  • Returns SQL to drop an index.


    Parameters

    Returns string

inheritedgetDropNamespaceSQL

  • getDropNamespaceSQL(name): string
  • Parameters

    • name: string

    Returns string

inheritedgetDropNativeEnumSQL

  • getDropNativeEnumSQL(name, schema): string
  • Parameters

    • name: string
    • optionalschema: string

    Returns string

inheritedgetListMaterializedViewsSQL

  • getListMaterializedViewsSQL(): string
  • Returns string

inheritedgetListTablesSQL

  • getListTablesSQL(): string
  • Returns the SQL query to list all tables in the database.


    Returns string

inheritedgetListViewsSQL

  • getListViewsSQL(): string
  • Returns string

getManagementDbName

  • getManagementDbName(): string
  • Returns string

inheritedgetNamespaces

  • getNamespaces(connection, ctx): Promise<string[]>
  • Parameters

    Returns Promise<string[]>

inheritedgetNativeEnumDefinitions

  • getNativeEnumDefinitions(connection, schemas, ctx): Promise<Dictionary<{ items: string[]; name: string; schema?: string }>>
  • Parameters

    Returns Promise<Dictionary<{ items: string[]; name: string; schema?: string }>>

inheritedgetPartitioningRebuildSQL

  • getPartitioningRebuildSQL(rebuilds, safe): string[]
  • Adding partitioning to an existing table (or changing an existing definition) can't be done in place in PostgreSQL, so we rebuild it: park the original table in a temp schema (its indexes/constraints/sequences move with it, freeing the names), create the new partitioned table, copy the data across, and restore the foreign keys that pointed at it. In safe mode the original table is kept in the temp schema for manual verification; otherwise the temp schema is dropped at the end.


    Parameters

    Returns string[]

inheritedgetPartitions

  • Introspects direct partitions only: the pg_inherits join surfaces a parent's children but does not recurse into sub-partitioning (e.g. hash-of-range). Declarative partitionBy metadata does not express multi-level partitioning either, so grandchildren are intentionally invisible to schema diffing.

    Entries with an undefined schema bucket are resolved against current_schema() so they do not match same-named tables in unrelated schemas.


    Parameters

    Returns Promise<Dictionary<TablePartitioning>>

inheritedgetPostAlterTable

  • getPostAlterTable(tableDiff, safe): string[]
  • Parameters

    Returns string[]

inheritedgetPreAlterTable

  • getPreAlterTable(tableDiff, safe): string[]
  • Parameters

    Returns string[]

inheritedgetPrimaryKeys

  • getPrimaryKeys(connection, indexes, tableName, schemaName): Promise<string[]>
  • Parameters

    Returns Promise<string[]>

inheritedgetReferencedTableName

  • getReferencedTableName(referencedTableName, schema): string
  • Parameters

    • referencedTableName: string
    • optionalschema: string

    Returns string

inheritedgetRenameColumnSQL

  • getRenameColumnSQL(tableName, oldColumnName, to, schemaName): string
  • Returns SQL to rename a column in a table.


    Parameters

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

    Returns string

inheritedgetRenameIndexSQL

  • getRenameIndexSQL(tableName, index, oldIndexName): string[]
  • Parameters

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

    Returns string[]

inheritedgetResetSchemaSQL

  • getResetSchemaSQL(_defaultSchema): string
  • Restores the session's schema to the connection's default after a migration.


    Parameters

    • _defaultSchema: string

    Returns string

inheritedgetSchemaBeginning

  • getSchemaBeginning(charset, disableForeignKeys): string
  • Returns SQL to prepend to schema migration scripts (e.g., disabling FK checks).


    Parameters

    • charset: string
    • optionaldisableForeignKeys: boolean

    Returns string

inheritedgetSchemaEnd

  • getSchemaEnd(disableForeignKeys): string
  • Returns SQL to append to schema migration scripts (e.g., re-enabling FK checks).


    Parameters

    • optionaldisableForeignKeys: boolean

    Returns string

inheritedgetSetSchemaSQL

  • getSetSchemaSQL(schema): string
  • Sets the current schema for the session (e.g. SET search_path).


    Parameters

    • schema: string

    Returns string

inheritedgetTablesGroupedBySchemas

  • getTablesGroupedBySchemas(tables): Map<undefined | string, Table[]>
  • Parameters

    Returns Map<undefined | string, Table[]>

inheritedhasNonDefaultPrimaryKeyName

  • hasNonDefaultPrimaryKeyName(table): boolean
  • Parameters

    • table: DatabaseTable

    Returns boolean

inheritedinferLengthFromColumnType

  • inferLengthFromColumnType(type): undefined | number
  • Parameters

    • type: string

    Returns undefined | number

inheritedloadInformationSchema

  • loadInformationSchema(schema, connection, tables, schemas, ctx): Promise<void>
  • Loads table metadata (columns, indexes, foreign keys) from the database information schema.


    Parameters

    Returns Promise<void>

inheritedloadMaterializedViews

  • loadMaterializedViews(schema, connection, schemaName, ctx): Promise<void>
  • Parameters

    Returns Promise<void>

inheritedloadViews

  • loadViews(schema, connection, schemaName, ctx): Promise<void>
  • Parameters

    Returns Promise<void>

inheritedmapForeignKeys

  • mapForeignKeys(fks, tableName, schemaName): Dictionary
  • Parameters

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

    Returns Dictionary

inheritednormaliseRoutineParamDirection

  • normaliseRoutineParamDirection(direction): in | out | inout
  • T-SQL doesn't distinguish OUT from INOUT in the catalog — overrides fold 'out' into 'inout'.


    Parameters

    • direction: in | out | inout

    Returns in | out | inout

inheritednormalizeDefaultValue

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

    • defaultValue: string
    • length: number

    Returns string | number

inheritedrefreshMaterializedView

  • refreshMaterializedView(name, schema, concurrently): string
  • Parameters

    • name: string
    • optionalschema: string
    • concurrently: boolean = false

    Returns string

inheritedresolveMigrationSchema

  • resolveMigrationSchema(schema): undefined | string
  • Returns undefined for schemaless drivers, throws for drivers that have schemas but no session switch.


    Parameters

    • schema: undefined | string

    Returns undefined | string

inheritedroutineParamReference

  • routineParamReference(name): string
  • T-SQL requires @name inside the body; PG/MySQL/Oracle use the bare name.


    Parameters

    • name: string

    Returns string

inheritedsplitTableName

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

    • name: string
    • skipDefaultSchema: boolean = false

    Returns [undefined | string, string]

inheritedsupportsMigrationSchema

  • supportsMigrationSchema(): boolean
  • Whether the driver supports setting a runtime schema per migration run.


    Returns boolean

inheritedsupportsSchemaConstraints

  • supportsSchemaConstraints(): boolean
  • Returns boolean

inheritedtableExists

  • tableExists(connection, tableName, schemaName, ctx): Promise<boolean>
  • Checks whether a specific table exists in a given schema (not the connection's current schema).


    Parameters

    Returns Promise<boolean>

Page Options