import { type ClearDatabaseOptions, type CreateSchemaOptions, type DropSchemaOptions, type EnsureDatabaseOptions, type EntityMetadata, type ISchemaGenerator, type MikroORM, type Options, type Transaction, type UpdateSchemaOptions, } from '@mikro-orm/core'; import { AbstractSchemaGenerator } from '@mikro-orm/core/schema'; import type { SchemaDifference } from '../typings.js'; import { DatabaseSchema } from './DatabaseSchema.js'; import type { AbstractSqlDriver } from '../AbstractSqlDriver.js'; import type { SchemaHelper } from './SchemaHelper.js'; /** Generates and manages SQL database schemas based on entity metadata. Supports create, update, and drop operations. */ export declare class SqlSchemaGenerator extends AbstractSchemaGenerator implements ISchemaGenerator { protected readonly helper: SchemaHelper; protected readonly options: NonNullable; protected lastEnsuredDatabase?: string; static register(orm: MikroORM): void; create(options?: CreateSchemaOptions): Promise; /** * Returns true if the database was created. */ ensureDatabase(options?: EnsureDatabaseOptions): Promise; getTargetSchema(schema?: string): DatabaseSchema; protected getOrderedMetadata(schema?: string): EntityMetadata[]; getCreateSchemaSQL(options?: CreateSchemaOptions): Promise; drop(options?: DropSchemaOptions): Promise; createNamespace(name: string): Promise; dropNamespace(name: string): Promise; clear(options?: ClearDatabaseOptions): Promise; getDropSchemaSQL(options?: Omit): Promise; private getSchemaName; update(options?: UpdateSchemaOptions): Promise; getUpdateSchemaSQL(options?: UpdateSchemaOptions): Promise; getUpdateSchemaMigrationSQL(options?: UpdateSchemaOptions): Promise<{ up: string; down: string; }>; private prepareSchemaForComparison; diffToSQL( schemaDiff: SchemaDifference, options: { wrap?: boolean; safe?: boolean; dropTables?: boolean; schema?: string; }, ): string; /** * We need to drop foreign keys first for all tables to allow dropping PK constraints. */ private preAlterTable; /** * creates new database and connects to it */ createDatabase( name?: string, options?: { skipOnConnect?: boolean; }, ): Promise; dropDatabase(name?: string): Promise; execute( sql: string, options?: { wrap?: boolean; ctx?: Transaction; }, ): Promise; dropTableIfExists(name: string, schema?: string): Promise; private wrapSchema; private append; private matchName; private isTableSkipped; /** * Sorts views by their dependencies so that views depending on other views are created after their dependencies. * Uses topological sort based on view definition string matching. */ private sortViewsByDependencies; private escapeRegExp; } export { SqlSchemaGenerator as SchemaGenerator };