23 lines
664 B
TypeScript
23 lines
664 B
TypeScript
/**
|
|
* Abstract base class for database migrations.
|
|
* All migrations must extend this class and implement the abstract members.
|
|
*/
|
|
|
|
import type { TQueryFunction } from '../types.ts';
|
|
|
|
export abstract class BaseMigration {
|
|
/** The migration version number (must be unique and sequential) */
|
|
abstract readonly version: number;
|
|
|
|
/** A short description of what this migration does */
|
|
abstract readonly description: string;
|
|
|
|
/** Execute the migration's SQL statements */
|
|
abstract up(query: TQueryFunction): void;
|
|
|
|
/** Returns a human-readable name for logging */
|
|
getName(): string {
|
|
return `Migration ${this.version}: ${this.description}`;
|
|
}
|
|
}
|