nestjs-reverse-engineering
Version:
A powerful TypeScript/NestJS library for database reverse engineering, entity generation, and CRUD operations
84 lines • 2.21 kB
TypeScript
import { DatabaseDialect, TableSchema } from '../types/database.types';
export interface SqlGenerationOptions {
dialect: DatabaseDialect;
schemaName?: string;
includeDropIfExists: boolean;
includeCreateIfNotExists: boolean;
includeComments: boolean;
engineType?: string;
charset?: string;
collation?: string;
tablespace?: string;
fillfactor?: number;
withOids?: boolean;
outputPath?: string;
}
export interface SqlScriptResult {
sql: string;
tableCount: number;
dialect: DatabaseDialect;
options: SqlGenerationOptions;
}
export declare class SqlGenerator {
private readonly typeMapper;
private readonly namingUtils;
private readonly options;
constructor(options?: Partial<SqlGenerationOptions>);
/**
* Generate CREATE TABLE scripts from table schemas
*/
generateCreateTableScripts(tables: TableSchema[]): SqlScriptResult;
/**
* Generate CREATE TABLE script for a single table
*/
private generateSingleTableScript;
/**
* Generate column definition
*/
private generateColumnDefinition;
/**
* Get column data type with proper dialect mapping
*/
private getColumnDataType;
/**
* Format default value based on data type
*/
private formatDefaultValue;
/**
* Generate foreign key constraints
*/
private generateForeignKeyConstraints;
/**
* Add dialect-specific setup commands
*/
private addDialectSpecificSetup;
/**
* Add table-specific options
*/
private addTableOptions;
/**
* Add column comments
*/
private addColumnComments;
/**
* Add indexes
*/
private addIndexes;
/**
* Get full table name with schema prefix
*/
private getFullTableName;
/**
* Escape SQL identifiers
*/
private escapeIdentifier;
/**
* Save SQL script to file
*/
saveSqlScript(result: SqlScriptResult, filename?: string): Promise<string>;
/**
* Generate SQL from entity files in directory
*/
generateFromEntityDirectory(entitiesPath: string): Promise<SqlScriptResult>;
}
//# sourceMappingURL=sql-generator.d.ts.map