PgliteSchemaHelper
Hierarchy
- PostgreSqlSchemaHelper
- PgliteSchemaHelper
Index
Constructors
Properties
Accessors
Methods
- alterTable
- alterTableColumn
- alterTableComment
- append
- appendComments
- castColumn
- createCheck
- createForeignKey
- createIndex
- createMaterializedView
- createRoutine
- createTable
- createTableColumn
- createTrigger
- createView
- databaseExists
- disableForeignKeysSQL
- dropConstraint
- dropForeignKey
- dropIndex
- dropMaterializedViewIfExists
- dropRoutine
- dropTableIfExists
- dropTrigger
- dropViewIfExists
- enableForeignKeysSQL
- finalizeTable
- getAddColumnsSQL
- getAllChecks
- getAllColumns
- getAllForeignKeys
- getAllIndexes
- getAllRoutines
- getAllTables
- getAllTriggers
- getAlterNativeEnumSQL
- getChangeColumnCommentSQL
- getCreateDatabaseSQL
- getCreateIndexSQL
- getCreateNamespaceSQL
- getCreateNativeEnumSQL
- getDatabaseCollation
- getDatabaseExistsSQL
- getDatabaseNotExistsError
- getDefaultEmptyString
- getDropColumnsSQL
- getDropDatabaseSQL
- getDropIndexSQL
- getDropNamespaceSQL
- getDropNativeEnumSQL
- getListMaterializedViewsSQL
- getListTablesSQL
- getListViewsSQL
- getManagementDbName
- getNamespaces
- getNativeEnumDefinitions
- getPartitions
- getPostAlterTable
- getPreAlterTable
- getPrimaryKeys
- getReferencedTableName
- getRenameColumnSQL
- getRenameIndexSQL
- getResetSchemaSQL
- getSchemaBeginning
- getSchemaEnd
- getSetSchemaSQL
- getTablesGroupedBySchemas
- hasNonDefaultPrimaryKeyName
- inferLengthFromColumnType
- loadInformationSchema
- loadMaterializedViews
- loadViews
- mapForeignKeys
- normaliseRoutineParamDirection
- normalizeDefaultValue
- refreshMaterializedView
- resolveMigrationSchema
- routineParamReference
- splitTableName
- supportsMigrationSchema
- supportsSchemaConstraints
- tableExists
Constructors
constructor
Parameters
platform: AbstractSqlPlatform
Returns PgliteSchemaHelper
Properties
staticreadonlyinheritedDEFAULT_VALUES
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
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; ignoreSchema?: string[]; 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.optionalignoreSchema?: string[]
Schema names to ignore when comparing schemas.
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
Returns SQL statements to apply a table difference (add/drop/alter columns, indexes, foreign keys).
Parameters
diff: TableDifference
optionalsafe: boolean
Returns string[]
inheritedalterTableColumn
Parameters
column: Column
table: DatabaseTable
changedProperties: Set<string>
Returns string[]
inheritedalterTableComment
Parameters
table: DatabaseTable
optionalcomment: string
Returns string
inheritedappend
Parameters
array: string[]
sql: string | string[]
pad: boolean = false
Returns void
inheritedappendComments
Parameters
table: DatabaseTable
Returns string[]
inheritedcastColumn
Parameters
name: string
type: string
Returns string
inheritedcreateCheck
Parameters
table: DatabaseTable
check: CheckDef<unknown>
Returns string
inheritedcreateForeignKey
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
Parameters
index: IndexDef
table: DatabaseTable
createPrimary: boolean = false
Returns string
inheritedcreateMaterializedView
Parameters
name: string
schema: undefined | string
definition: string
withData: boolean = true
Returns string
inheritedcreateRoutine
Default no-op so SQLite/libSQL silent-skip routine DDL; routine-capable dialects override.
Parameters
routine: SqlRoutineDef
Returns string
inheritedcreateTable
Returns SQL statements to create a table with all its columns, primary key, indexes, and checks.
Parameters
table: DatabaseTable
optionalalter: boolean
Returns string[]
inheritedcreateTableColumn
Parameters
column: Column
table: DatabaseTable
Returns undefined | string
inheritedcreateTrigger
Generates SQL to create a PostgreSQL trigger and its associated function.
Parameters
table: DatabaseTable
trigger: SqlTriggerDef
Returns string
inheritedcreateView
Parameters
name: string
schema: undefined | string
definition: string
Returns string
databaseExists
Parameters
_connection: Connection
_name: string
Returns Promise<boolean>
inheriteddisableForeignKeysSQL
Returns SQL to disable foreign key checks.
Returns string
inheriteddropConstraint
Parameters
table: string
name: string
Returns string
inheriteddropForeignKey
Parameters
tableName: string
constraintName: string
Returns string
inheriteddropIndex
Parameters
table: string
index: IndexDef
oldIndexName: string = index.keyName
Returns string
inheriteddropMaterializedViewIfExists
Parameters
name: string
optionalschema: string
Returns string
inheriteddropRoutine
Parameters
routine: SqlRoutineDef
Returns string
inheriteddropTableIfExists
Returns SQL to drop a table if it exists.
Parameters
name: string
optionalschema: string
Returns string
inheriteddropTrigger
Generates SQL to drop a PostgreSQL trigger and its associated function.
Parameters
table: DatabaseTable
trigger: SqlTriggerDef
Returns string
inheriteddropViewIfExists
Parameters
name: string
optionalschema: string
Returns string
inheritedenableForeignKeysSQL
Returns SQL to re-enable foreign key checks.
Returns string
inheritedfinalizeTable
Parameters
table: DatabaseTable
charset: string
optionalcollate: string
Returns string
inheritedgetAddColumnsSQL
Returns SQL to add columns to an existing table.
Parameters
table: DatabaseTable
columns: Column[]
Returns string[]
inheritedgetAllChecks
Parameters
connection: AbstractSqlConnection
tablesBySchemas: Map<undefined | string, Table[]>
optionalctx: any
Returns Promise<Dictionary<CheckDef<unknown>[]>>
inheritedgetAllColumns
Parameters
connection: AbstractSqlConnection
tablesBySchemas: Map<undefined | string, Table[]>
optionalnativeEnums: Dictionary<{ items: string[]; name: string; schema?: string }>
optionalctx: any
Returns Promise<Dictionary<Column[]>>
inheritedgetAllForeignKeys
Parameters
connection: AbstractSqlConnection
tablesBySchemas: Map<undefined | string, Table[]>
optionalctx: any
Returns Promise<Dictionary<Dictionary<ForeignKey>>>
inheritedgetAllIndexes
Parameters
connection: AbstractSqlConnection
tables: Table[]
optionalctx: any
Returns Promise<Dictionary<IndexDef[]>>
inheritedgetAllRoutines
Parameters
connection: AbstractSqlConnection
schemas: string[] = []
Returns Promise<SqlRoutineDef[]>
inheritedgetAllTables
Retrieves all tables from the database.
Parameters
connection: AbstractSqlConnection
optionalschemas: string[]
optionalctx: any
Returns Promise<Table[]>
inheritedgetAllTriggers
Parameters
connection: AbstractSqlConnection
tablesBySchemas: Map<undefined | string, Table[]>
Returns Promise<Dictionary<SqlTriggerDef[]>>
inheritedgetAlterNativeEnumSQL
Parameters
name: string
optionalschema: string
optionalvalue: string
optionalitems: string[]
optionaloldItems: string[]
Returns string
inheritedgetChangeColumnCommentSQL
Parameters
tableName: string
to: Column
optionalschemaName: string
Returns string
getCreateDatabaseSQL
Returns string
inheritedgetCreateIndexSQL
Returns SQL to create an index on a table.
Parameters
tableName: string
index: IndexDef
Returns string
inheritedgetCreateNamespaceSQL
Parameters
name: string
Returns string
inheritedgetCreateNativeEnumSQL
Parameters
name: string
values: unknown[]
optionalschema: string
Returns string
inheritedgetDatabaseCollation
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
connection: AbstractSqlConnection
optionalctx: any
Returns Promise<undefined | string>
inheritedgetDatabaseExistsSQL
Parameters
name: string
Returns string
inheritedgetDatabaseNotExistsError
Parameters
dbName: string
Returns string
inheritedgetDefaultEmptyString
Returns string
inheritedgetDropColumnsSQL
Parameters
tableName: string
columns: Column[]
optionalschemaName: string
Returns string
getDropDatabaseSQL
Returns string
inheritedgetDropIndexSQL
Returns SQL to drop an index.
Parameters
tableName: string
index: IndexDef
Returns string
inheritedgetDropNamespaceSQL
Parameters
name: string
Returns string
inheritedgetDropNativeEnumSQL
Parameters
name: string
optionalschema: string
Returns string
inheritedgetListMaterializedViewsSQL
Returns string
inheritedgetListTablesSQL
Returns the SQL query to list all tables in the database.
Returns string
inheritedgetListViewsSQL
Returns string
getManagementDbName
Returns string
inheritedgetNamespaces
Parameters
connection: AbstractSqlConnection
optionalctx: any
Returns Promise<string[]>
inheritedgetNativeEnumDefinitions
Parameters
connection: AbstractSqlConnection
schemas: string[]
optionalctx: any
Returns Promise<Dictionary<{ items: string[]; name: string; schema?: string }>>
inheritedgetPartitions
Introspects direct partitions only: the
pg_inheritsjoin surfaces a parent's children but does not recurse into sub-partitioning (e.g. hash-of-range). DeclarativepartitionBymetadata 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
connection: AbstractSqlConnection
tablesBySchemas: Map<undefined | string, Table[]>
optionalctx: any
Returns Promise<Dictionary<TablePartitioning>>
inheritedgetPostAlterTable
Parameters
tableDiff: TableDifference
safe: boolean
Returns string[]
inheritedgetPreAlterTable
Parameters
tableDiff: TableDifference
safe: boolean
Returns string[]
inheritedgetPrimaryKeys
Parameters
connection: AbstractSqlConnection
indexes: IndexDef[] = []
tableName: string
optionalschemaName: string
Returns Promise<string[]>
inheritedgetReferencedTableName
Parameters
referencedTableName: string
optionalschema: string
Returns string
inheritedgetRenameColumnSQL
Returns SQL to rename a column in a table.
Parameters
tableName: string
oldColumnName: string
to: Column
optionalschemaName: string
Returns string
inheritedgetRenameIndexSQL
Parameters
tableName: string
index: IndexDef
oldIndexName: string
Returns string[]
inheritedgetResetSchemaSQL
Restores the session's schema to the connection's default after a migration.
Parameters
_defaultSchema: string
Returns string
inheritedgetSchemaBeginning
Returns SQL to prepend to schema migration scripts (e.g., disabling FK checks).
Parameters
charset: string
optionaldisableForeignKeys: boolean
Returns string
inheritedgetSchemaEnd
Returns SQL to append to schema migration scripts (e.g., re-enabling FK checks).
Parameters
optionaldisableForeignKeys: boolean
Returns string
inheritedgetSetSchemaSQL
Sets the current schema for the session (e.g.
SET search_path).Parameters
schema: string
Returns string
inheritedgetTablesGroupedBySchemas
inheritedhasNonDefaultPrimaryKeyName
Parameters
table: DatabaseTable
Returns boolean
inheritedinferLengthFromColumnType
Parameters
type: string
Returns undefined | number
inheritedloadInformationSchema
Loads table metadata (columns, indexes, foreign keys) from the database information schema.
Parameters
schema: DatabaseSchema
connection: AbstractSqlConnection
tables: Table[]
optionalschemas: string[]
optionalctx: any
Returns Promise<void>
inheritedloadMaterializedViews
Parameters
schema: DatabaseSchema
connection: AbstractSqlConnection
optionalschemaName: string
optionalctx: any
Returns Promise<void>
inheritedloadViews
Parameters
schema: DatabaseSchema
connection: AbstractSqlConnection
optionalschemaName: string
optionalctx: any
Returns Promise<void>
inheritedmapForeignKeys
Parameters
fks: any[]
tableName: string
optionalschemaName: string
Returns Dictionary
inheritednormaliseRoutineParamDirection
T-SQL doesn't distinguish
OUTfromINOUTin the catalog — overrides fold'out'into'inout'.Parameters
direction: in | out | inout
Returns in | out | inout
inheritednormalizeDefaultValue
Parameters
defaultValue: string
length: number
Returns string | number
inheritedrefreshMaterializedView
Parameters
name: string
optionalschema: string
concurrently: boolean = false
Returns string
inheritedresolveMigrationSchema
Returns
undefinedfor schemaless drivers, throws for drivers that have schemas but no session switch.Parameters
schema: undefined | string
Returns undefined | string
inheritedroutineParamReference
T-SQL requires
@nameinside the body; PG/MySQL/Oracle use the bare name.Parameters
name: string
Returns string
inheritedsplitTableName
Parameters
name: string
skipDefaultSchema: boolean = false
Returns [undefined | string, string]
inheritedsupportsMigrationSchema
Whether the driver supports setting a runtime schema per migration run.
Returns boolean
inheritedsupportsSchemaConstraints
Returns boolean
inheritedtableExists
Checks whether a specific table exists in a given schema (not the connection's current schema).
Parameters
connection: AbstractSqlConnection
tableName: string
schemaName: undefined | string
optionalctx: any
Returns Promise<boolean>
PGlite is a single-database engine — there is no management catalog and no
CREATE DATABASE. Override the relevant lifecycle hooks to no-ops.