garrettmills
fcce28081b
All checks were successful
continuous-integration/drone/push Build is passing
40 lines
932 B
TypeScript
40 lines
932 B
TypeScript
import {Injectable} from '../../di'
|
|
import {Awaitable} from '../../util'
|
|
|
|
/**
|
|
* Abstract base-class for one-time migrations.
|
|
*/
|
|
@Injectable()
|
|
export abstract class Migration {
|
|
/** Set by the Migrations unit on load. */
|
|
protected migrationIdentifier!: string
|
|
|
|
/**
|
|
* Sets the migration identifier.
|
|
* This is used internally when the Migrations service loads
|
|
* the migration files to determine the ID from the file-name.
|
|
* It shouldn't be used externally.
|
|
* @param name
|
|
*/
|
|
public setMigrationIdentifier(name: string): void {
|
|
this.migrationIdentifier = name
|
|
}
|
|
|
|
/**
|
|
* Get the unique identifier of this migration.
|
|
*/
|
|
public get identifier(): string {
|
|
return this.migrationIdentifier
|
|
}
|
|
|
|
/**
|
|
* Apply the migration.
|
|
*/
|
|
abstract up(): Awaitable<void>
|
|
|
|
/**
|
|
* Undo the migration.
|
|
*/
|
|
abstract down(): Awaitable<void>
|
|
}
|