84 lines
2.6 KiB
TypeScript
84 lines
2.6 KiB
TypeScript
import { type Configuration, type Dictionary, type EntityMetadata } from '@mikro-orm/core';
|
|
import { DatabaseTable } from './DatabaseTable.js';
|
|
import type { AbstractSqlConnection } from '../AbstractSqlConnection.js';
|
|
import type { DatabaseView } from '../typings.js';
|
|
import type { AbstractSqlPlatform } from '../AbstractSqlPlatform.js';
|
|
/**
|
|
* @internal
|
|
*/
|
|
export declare class DatabaseSchema {
|
|
#private;
|
|
readonly name: string;
|
|
constructor(platform: AbstractSqlPlatform, name: string);
|
|
addTable(name: string, schema: string | undefined | null, comment?: string): DatabaseTable;
|
|
getTables(): DatabaseTable[];
|
|
/** @internal */
|
|
setTables(tables: DatabaseTable[]): void;
|
|
/** @internal */
|
|
setNamespaces(namespaces: Set<string>): void;
|
|
getTable(name: string): DatabaseTable | undefined;
|
|
hasTable(name: string): boolean;
|
|
addView(
|
|
name: string,
|
|
schema: string | undefined | null,
|
|
definition: string,
|
|
materialized?: boolean,
|
|
withData?: boolean,
|
|
): DatabaseView;
|
|
getViews(): DatabaseView[];
|
|
/** @internal */
|
|
setViews(views: DatabaseView[]): void;
|
|
getView(name: string): DatabaseView | undefined;
|
|
hasView(name: string): boolean;
|
|
setNativeEnums(
|
|
nativeEnums: Dictionary<{
|
|
name: string;
|
|
schema?: string;
|
|
items: string[];
|
|
}>,
|
|
): void;
|
|
getNativeEnums(): Dictionary<{
|
|
name: string;
|
|
schema?: string;
|
|
items: string[];
|
|
}>;
|
|
getNativeEnum(name: string): {
|
|
name: string;
|
|
schema?: string;
|
|
items: string[];
|
|
};
|
|
hasNamespace(namespace: string): boolean;
|
|
hasNativeEnum(name: string): boolean;
|
|
getNamespaces(): string[];
|
|
static create(
|
|
connection: AbstractSqlConnection,
|
|
platform: AbstractSqlPlatform,
|
|
config: Configuration,
|
|
schemaName?: string,
|
|
schemas?: string[],
|
|
takeTables?: (string | RegExp)[],
|
|
skipTables?: (string | RegExp)[],
|
|
skipViews?: (string | RegExp)[],
|
|
): Promise<DatabaseSchema>;
|
|
static fromMetadata(
|
|
metadata: EntityMetadata[],
|
|
platform: AbstractSqlPlatform,
|
|
config: Configuration,
|
|
schemaName?: string,
|
|
em?: any,
|
|
): DatabaseSchema;
|
|
private static getViewDefinition;
|
|
private static getSchemaName;
|
|
/**
|
|
* Add a foreign key from a TPT child entity's PK to its parent entity's PK.
|
|
* This FK uses ON DELETE CASCADE to ensure child rows are deleted when parent is deleted.
|
|
*/
|
|
private static addTPTForeignKey;
|
|
private static matchName;
|
|
private static isNameAllowed;
|
|
private static isTableNameAllowed;
|
|
private static shouldHaveColumn;
|
|
toJSON(): Dictionary;
|
|
prune(schema: string | undefined, wildcardSchemaTables: string[]): void;
|
|
}
|