import { AbstractDialect } from '../dialect/index.js'; import type { CanonicalType, ColumnNode, ForeignKeyAction, IndexNode, TableNode } from '../schema/types.js'; import type { ColumnSchema, Dialect, EntityMeta, FieldOptions, IndexSchema, NamingStrategy, SchemaDiff, SchemaGenerator, Type } from '../type/index.js'; import type { FullColumnDefinition, TableDefinition, TableForeignKeyDefinition } from './builder/types.js'; /** * Unified SQL schema generator. * Parameterized by dialect to handle Postgres, MySQL, MariaDB, and SQLite. */ export declare class SqlSchemaGenerator extends AbstractDialect implements SchemaGenerator { /** * Escape an identifier (table name, column name, etc.) */ protected escapeId(identifier: string): string; /** * Primary key type for auto-increment integer IDs */ protected get serialPrimaryKeyType(): string; /** * Convert FieldOptions to CanonicalType using the unified type system. */ protected getCanonicalType(field: FieldOptions, fieldType?: unknown): CanonicalType; /** * Convert CanonicalType to SQL type string for this dialect. * Also handles legacy string types for backward compatibility. */ protected canonicalTypeToSql(type: CanonicalType | string): string; generateCreateTable(entity: Type, options?: { ifNotExists?: boolean; }): string; generateDropTable(entity: Type): string; generateAlterTable(diff: SchemaDiff): string[]; generateAlterTableDown(diff: SchemaDiff): string[]; generateCreateIndex(tableName: string, index: IndexSchema): string; generateDropIndex(tableName: string, indexName: string): string; /** * Generate column definition from a ColumnSchema object */ generateColumnDefinitionFromSchema(column: ColumnSchema, options?: { includePrimaryKey?: boolean; includeUnique?: boolean; }): string; getSqlType(field: FieldOptions, fieldType?: unknown): string; /** * Get the boolean type for this database */ getBooleanType(): string; /** * Generate ALTER COLUMN statements (database-specific) */ generateAlterColumnStatements(tableName: string, column: ColumnSchema, newDefinition: string): string[]; /** * Get table options (e.g., ENGINE for MySQL) */ getTableOptions(_meta: EntityMeta): string; /** * Generate column comment clause (if supported) */ generateColumnComment(columnName: string, comment: string): string; /** * Format a default value for SQL */ formatDefaultValue(value: unknown): string; /** * Compare an entity with a database table node and return the differences. */ diffSchema(entity: Type, currentTable: TableNode | undefined): SchemaDiff | undefined; private columnNodeToSchema; /** * Convert field options to ColumnSchema */ protected fieldToColumnSchema(fieldKey: string, field: FieldOptions, meta: EntityMeta): ColumnSchema; /** * Check if two columns differ enough to require alteration */ protected columnsNeedAlteration(current: ColumnSchema, desired: ColumnSchema): boolean; /** * Compare two column types for equality using the canonical type system */ protected isTypeEqual(current: ColumnSchema, desired: ColumnSchema): boolean; /** * Compare two default values for equality */ protected isDefaultValueEqual(current: unknown, desired: unknown): boolean; /** * Generate CREATE TABLE SQL from a TableNode. */ generateCreateTableFromNode(table: TableNode, options?: { ifNotExists?: boolean; }): string; /** * Generate a column definition from a ColumnNode. */ protected generateColumnFromNode(col: ColumnNode): string; /** * Generate CREATE INDEX SQL from an IndexNode. */ generateCreateIndexFromNode(index: IndexNode, options?: { ifNotExists?: boolean; }): string; /** * Generate DROP TABLE SQL from a TableNode. */ generateDropTableFromNode(table: TableNode, options?: { ifExists?: boolean; }): string; generateCreateTableFromDefinition(table: TableDefinition, options?: { ifNotExists?: boolean; }): string; generateDropTableSql(tableName: string, options?: { ifExists?: boolean; cascade?: boolean; }): string; generateRenameTableSql(oldName: string, newName: string): string; generateAddColumnSql(tableName: string, column: FullColumnDefinition): string; generateAlterColumnSql(tableName: string, columnName: string, column: FullColumnDefinition): string; generateDropColumnSql(tableName: string, columnName: string): string; generateRenameColumnSql(tableName: string, oldName: string, newName: string): string; generateCreateIndexSql(tableName: string, index: IndexSchema): string; generateDropIndexSql(tableName: string, indexName: string): string; generateAddForeignKeySql(tableName: string, foreignKey: TableForeignKeyDefinition): string; generateDropForeignKeySql(tableName: string, constraintName: string): string; private tableDefinitionToNode; private fullColumnDefinitionToNode; } import { MongoSchemaGenerator } from './generator/mongoSchemaGenerator.js'; export { MongoSchemaGenerator }; /** * Factory function to create a SchemaGenerator for a specific dialect. * Returns undefined for unsupported dialects. */ export declare function createSchemaGenerator(dialect: Dialect, namingStrategy?: NamingStrategy, defaultForeignKeyAction?: ForeignKeyAction): SchemaGenerator | undefined; //# sourceMappingURL=schemaGenerator.d.ts.map