docs(cli): document the relative file path support for the "remove" command

This commit is contained in:
Joakim Carlstein 2024-01-26 15:21:44 +01:00 committed by Joakim Carlstein
parent 2f6b4d23e0
commit 0faebbe647
4 changed files with 35 additions and 9 deletions

View file

@ -0,0 +1,5 @@
---
'@emigrate/cli': minor
---
Add support for passing the relative path to a migration file to remove from the history using the "remove" command

View file

@ -13,22 +13,22 @@ The `remove` command is used to remove a migration from the history. This is use
<Tabs>
<TabItem label="npm">
```bash
npx emigrate remove [options] <name>
npx emigrate remove [options] <name/path>
```
</TabItem>
<TabItem label="pnpm">
```bash
pnpm emigrate remove [options] <name>
pnpm emigrate remove [options] <name/path>
```
</TabItem>
<TabItem label="yarn">
```bash
yarn emigrate remove [options] <name>
yarn emigrate remove [options] <name/path>
```
</TabItem>
<TabItem label="bun">
```bash
bunx --bun emigrate remove [options] <name>
bunx --bun emigrate remove [options] <name/path>
```
</TabItem>
<TabItem label="deno">
@ -44,16 +44,18 @@ The `remove` command is used to remove a migration from the history. This is use
```
```bash
deno task emigrate remove [options] <name>
deno task emigrate remove [options] <name/path>
```
</TabItem>
</Tabs>
## Arguments
### `<name>`
### `<name/path>`
The name of the migration file to remove, including the extension, e.g. `20200101000000_some_migration.js`.
The name of the migration file to remove, including the extension, e.g. `20200101000000_some_migration.js`, or a relative file path to a migration file to remove, e.g: `migrations/20200101000000_some_migration.js`.
Using relative file paths is useful in terminals that support autocomplete, and also when you copy and use the relative migration file path from the output of the <Link href="/commands/list/">`list`</Link> command.
## Options

View file

@ -20,6 +20,24 @@ bun add @emigrate/cli
## Usage
```text
Usage: emigrate <options>/<command>
Options:
-h, --help Show this help message and exit
-v, --version Print version number and exit
Commands:
up Run all pending migrations (or do a dry run)
new Create a new migration file
list List all migrations and their status
remove Remove entries from the migration history
```
### `emigrate up`
```text
Usage: emigrate up [options]

View file

@ -440,14 +440,14 @@ const remove: Action = async (args) => {
allowPositionals: true,
});
const usage = `Usage: emigrate remove [options] <name>
const usage = `Usage: emigrate remove [options] <name/path>
Remove entries from the migration history.
This is useful if you want to retry a migration that has failed.
Arguments:
name The name of the migration file to remove from the history (required)
name/path The name of or relative path to the migration file to remove from the history (required)
Options:
@ -466,6 +466,7 @@ Examples:
emigrate remove -d migrations -s fs 20231122120529381_some_migration_file.js
emigrate remove --directory ./migrations --storage postgres 20231122120529381_some_migration_file.sql
emigrate remove -i dotenv/config -d ./migrations -s postgres 20231122120529381_some_migration_file.sql
emigrate remove -i dotenv/config -d ./migrations -s postgres migrations/20231122120529381_some_migration_file.sql
`;
if (values.help) {