Models & Enums
Model classes and enumeration types.
Table of contents
Model Classes
MigrationScript
Represents a migration script file.
class MigrationScript {
timestamp: number;
name: string;
filepath: string;
script?: IMigrationScript;
startedAt?: number;
username?: string;
}
Properties
| Property | Type | Description |
|---|---|---|
timestamp | number | Migration version number |
name | string | Migration filename |
filepath | string | Absolute path to migration file |
script | IMigrationScript? | Loaded migration instance |
startedAt | number? | Execution start timestamp |
username | string? | User executing migration |
Methods
init()
Load and instantiate the migration script.
await migrationScript.init(): Promise<void>
Dynamically imports the migration file and creates an instance of the exported class.
Utility Classes
Utils
Internal utility functions (not typically used directly).
import { Utils } from '@migration-script-runner/core';
Methods
promiseAll()
Resolve all promises in an object, preserving keys.
static async promiseAll<T>(map: { [key: string]: Promise<T> }): Promise<{ [key: string]: T }>
Similar to Promise.all() but works with objects instead of arrays.
parseRunnable()
Parse and instantiate a migration script from a file path.
static async parseRunnable(filepath: string): Promise<IMigrationScript>
Parameters:
filepath: Absolute path to migration file
Returns: Instance of migration script
Throws: Error if file cannot be parsed or doesn’t contain valid migration