forge-sql-orm-cli
Version:
CLI tool for Forge SQL ORM
47 lines (46 loc) • 1.81 kB
TypeScript
import "reflect-metadata";
/**
* Options for migration creation
*/
export interface CreateMigrationOptions {
output: string;
entitiesPath: string;
force?: boolean;
}
/**
* Loads the current migration version from `migrationCount.ts`.
* @param migrationPath - Path to the migration folder.
* @returns The latest migration version.
*/
export declare const loadMigrationVersion: (migrationPath: string) => Promise<number>;
/**
* Cleans SQL statements by removing unnecessary database options.
* @param sql - The raw SQL statement.
* @returns The cleaned SQL statement.
*/
export declare function cleanSQLStatement(sql: string): string;
/**
* Generates a migration file using the provided SQL statements.
* @param createStatements - Array of SQL statements.
* @param version - Migration version number.
* @returns TypeScript migration file content.
*/
export declare function generateMigrationFile(createStatements: string[], version: number): string;
/**
* Saves the generated migration file along with `migrationCount.ts` and `index.ts`.
* @param migrationCode - The migration code to be written to the file.
* @param version - Migration version number.
* @param outputDir - Directory where the migration files will be saved.
*/
export declare function saveMigrationFiles(migrationCode: string, version: number, outputDir: string): void;
/**
* Extracts only the relevant SQL statements for migration.
* @param schema - The full database schema as SQL.
* @returns Filtered list of SQL statements.
*/
export declare const extractCreateStatements: (schema: string) => string[];
/**
* Creates a full database migration.
* @param options - Database connection settings and output paths.
*/
export declare const createMigration: (options: CreateMigrationOptions) => Promise<never>;