feat(remove): implement the "remove" command for removing migrations from the history

This commit is contained in:
Joakim Carlstein 2023-11-24 15:45:17 +01:00
parent 9447d28ad8
commit d8a6a2428a
12 changed files with 370 additions and 24 deletions

View file

@ -18,16 +18,12 @@ import {
import { type Config } from '../types.js';
import { withLeadingPeriod } from '../with-leading-period.js';
import { getMigrations } from '../get-migrations.js';
import { getDuration } from '../get-duration.js';
type ExtraFlags = {
dry?: boolean;
};
const getDuration = (start: [number, number]) => {
const [seconds, nanoseconds] = process.hrtime(start);
return seconds * 1000 + nanoseconds / 1_000_000;
};
const lazyDefaultReporter = async () => import('../reporters/default.js');
const lazyPluginLoaderJs = async () => import('../plugin-loader-js.js');
@ -81,7 +77,7 @@ export default async function upCommand({
relativeFilePath: path.relative(cwd, filePath),
extension: withLeadingPeriod(path.extname(migrationHistoryEntry.name)),
error: new MigrationHistoryError(
`Migration ${migrationHistoryEntry.name} is in a failed state, please fix it first`,
`Migration ${migrationHistoryEntry.name} is in a failed state, please fix and remove it first`,
migrationHistoryEntry,
),
directory,