Files
evento/node_modules/@mikro-orm/sql/dialects/postgresql/PostgreSqlSchemaHelper.d.ts
2026-03-18 14:55:56 -03:00

111 lines
4.9 KiB
TypeScript

import { type Dictionary } from '@mikro-orm/core';
import { SchemaHelper } from '../../schema/SchemaHelper.js';
import type { AbstractSqlConnection } from '../../AbstractSqlConnection.js';
import type { CheckDef, Column, ForeignKey, IndexDef, Table, TableDifference } from '../../typings.js';
import type { DatabaseSchema } from '../../schema/DatabaseSchema.js';
import type { DatabaseTable } from '../../schema/DatabaseTable.js';
export declare class PostgreSqlSchemaHelper extends SchemaHelper {
static readonly DEFAULT_VALUES: {
'now()': string[];
'current_timestamp(?)': string[];
"('now'::text)::timestamp(?) with time zone": string[];
"('now'::text)::timestamp(?) without time zone": string[];
'null::character varying': string[];
'null::timestamp with time zone': string[];
'null::timestamp without time zone': string[];
};
getSchemaBeginning(charset: string, disableForeignKeys?: boolean): string;
getCreateDatabaseSQL(name: string): string;
getListTablesSQL(): string;
private getIgnoredViewsCondition;
getListViewsSQL(): string;
loadViews(schema: DatabaseSchema, connection: AbstractSqlConnection): Promise<void>;
getListMaterializedViewsSQL(): string;
loadMaterializedViews(schema: DatabaseSchema, connection: AbstractSqlConnection, schemaName?: string): Promise<void>;
createMaterializedView(name: string, schema: string | undefined, definition: string, withData?: boolean): string;
dropMaterializedViewIfExists(name: string, schema?: string): string;
refreshMaterializedView(name: string, schema?: string, concurrently?: boolean): string;
getNamespaces(connection: AbstractSqlConnection): Promise<string[]>;
private getIgnoredNamespacesConditionSQL;
loadInformationSchema(
schema: DatabaseSchema,
connection: AbstractSqlConnection,
tables: Table[],
schemas?: string[],
): Promise<void>;
getAllIndexes(connection: AbstractSqlConnection, tables: Table[]): Promise<Dictionary<IndexDef[]>>;
/**
* Parses column definitions from the full CREATE INDEX expression.
* Since pg_get_indexdef(oid, col_num, true) doesn't include sort modifiers,
* we extract them from the full expression instead.
*
* We use columnDefs (from individual pg_get_indexdef calls) as the source
* of column names, and find their modifiers in the expression.
*/
private parseIndexColumnsFromExpression;
/**
* Extracts the content inside parentheses starting at the given position.
* Handles nested parentheses correctly.
*/
private extractParenthesizedContent;
getAllColumns(
connection: AbstractSqlConnection,
tablesBySchemas: Map<string | undefined, Table[]>,
nativeEnums?: Dictionary<{
name: string;
schema?: string;
items: string[];
}>,
): Promise<Dictionary<Column[]>>;
getAllChecks(
connection: AbstractSqlConnection,
tablesBySchemas: Map<string | undefined, Table[]>,
): Promise<Dictionary<CheckDef[]>>;
getAllForeignKeys(
connection: AbstractSqlConnection,
tablesBySchemas: Map<string | undefined, Table[]>,
): Promise<Dictionary<Dictionary<ForeignKey>>>;
getNativeEnumDefinitions(
connection: AbstractSqlConnection,
schemas: string[],
): Promise<
Dictionary<{
name: string;
schema?: string;
items: string[];
}>
>;
getCreateNativeEnumSQL(name: string, values: unknown[], schema?: string): string;
getDropNativeEnumSQL(name: string, schema?: string): string;
getAlterNativeEnumSQL(name: string, schema?: string, value?: string, items?: string[], oldItems?: string[]): string;
private getEnumDefinitions;
createTableColumn(column: Column, table: DatabaseTable): string | undefined;
getPreAlterTable(tableDiff: TableDifference, safe: boolean): string[];
castColumn(name: string, type: string): string;
dropForeignKey(tableName: string, constraintName: string): string;
getPostAlterTable(tableDiff: TableDifference, safe: boolean): string[];
private getAlterColumnAutoincrement;
getChangeColumnCommentSQL(tableName: string, to: Column, schemaName?: string): string;
alterTableComment(table: DatabaseTable, comment?: string): string;
normalizeDefaultValue(defaultValue: string, length: number): string | number;
appendComments(table: DatabaseTable): string[];
getDatabaseExistsSQL(name: string): string;
getDatabaseNotExistsError(dbName: string): string;
getManagementDbName(): string;
disableForeignKeysSQL(): string;
enableForeignKeysSQL(): string;
getRenameIndexSQL(tableName: string, index: IndexDef, oldIndexName: string): string[];
dropIndex(table: string, index: IndexDef, oldIndexName?: string): string;
/**
* Build the column list for a PostgreSQL index.
*/
protected getIndexColumns(index: IndexDef): string;
/**
* PostgreSQL-specific index options like fill factor.
*/
protected getCreateIndexSuffix(index: IndexDef): string;
private getIndexesSQL;
private getChecksSQL;
inferLengthFromColumnType(type: string): number | undefined;
}