feat(remove): rework the "remove" command to be more similar to "up" and "list"
The old reporter methods related to the "remove" command is not used anymore and instead the shared `onMigrationStart`, `onMigrationSuccess` and `onMigrationError` methods are used. Some preparation has also been made to support for removing multiple migrations at once in the future, similar to how the `--from` and `--to` CLI options work for the "up" command.
This commit is contained in:
parent
86e0d52e5c
commit
1f139fd975
12 changed files with 593 additions and 209 deletions
|
|
@ -137,6 +137,16 @@ export class MigrationNotRunError extends EmigrateError {
|
|||
}
|
||||
}
|
||||
|
||||
export class MigrationRemovalError extends EmigrateError {
|
||||
static fromMetadata(metadata: MigrationMetadata, cause?: Error) {
|
||||
return new MigrationRemovalError(`Failed to remove migration: ${metadata.relativeFilePath}`, { cause });
|
||||
}
|
||||
|
||||
constructor(message: string | undefined, options?: ErrorOptions) {
|
||||
super(message, options, 'ERR_MIGRATION_REMOVE');
|
||||
}
|
||||
}
|
||||
|
||||
export class StorageInitError extends EmigrateError {
|
||||
static fromError(error: Error) {
|
||||
return new StorageInitError('Could not initialize storage', { cause: error });
|
||||
|
|
@ -182,6 +192,7 @@ errorConstructors.set('MigrationHistoryError', MigrationHistoryError as unknown
|
|||
errorConstructors.set('MigrationLoadError', MigrationLoadError as unknown as ErrorConstructor);
|
||||
errorConstructors.set('MigrationRunError', MigrationRunError as unknown as ErrorConstructor);
|
||||
errorConstructors.set('MigrationNotRunError', MigrationNotRunError as unknown as ErrorConstructor);
|
||||
errorConstructors.set('MigrationRemovalError', MigrationRemovalError as unknown as ErrorConstructor);
|
||||
errorConstructors.set('StorageInitError', StorageInitError as unknown as ErrorConstructor);
|
||||
errorConstructors.set('CommandAbortError', CommandAbortError as unknown as ErrorConstructor);
|
||||
errorConstructors.set('ExecutionDesertedError', ExecutionDesertedError as unknown as ErrorConstructor);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue