UNPKG

flint-orm

Version:

Type-safe SQLite ORM for JavaScript

53 lines (52 loc) 1.86 kB
import type { Executor } from '../executor'; export interface MigrateOptions { /** Path to the migrations directory. */ migrationsDir: string; /** Dry run — show what would be applied without executing. */ dryRun?: boolean; } export interface MigrateResult { /** Names of migrations that were applied. */ applied: string[]; /** Names of migrations that were skipped (already applied). */ skipped: string[]; } /** * Apply pending migrations to a database. * * Reads the migrations directory, filters out already-applied migrations, * and applies the remaining ones in order within transactions. * * @param executor - The database executor (works with any driver) * @param options - Migration options * @returns Result with applied and skipped migration names * * @example * import { flint } from 'flint-orm/bun-sqlite'; * import { migrate } from 'flint-orm/migration'; * * const db = flint({ url: 'app.db' }); * const result = await migrate(db.$executor, { migrationsDir: './flint' }); * console.log(`Applied: ${result.applied.join(', ')}`); */ export declare function migrate(executor: Executor, options: MigrateOptions): Promise<MigrateResult>; export interface MigrationStatus { /** Applied migration names with their timestamps. */ applied: { name: string; folderName: string; }[]; /** Pending migration names. */ pending: { name: string; folderName: string; }[]; } /** * Get the status of migrations — which are applied and which are pending. * * @param executor - The database executor (works with any driver) * @param migrationsDir - Path to the migrations directory * @returns Status object with applied and pending migrations */ export declare function getMigrationStatus(executor: Executor, migrationsDir: string): Promise<MigrationStatus>;