> ## Documentation Index
> Fetch the complete documentation index at: https://docs.talosjs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# migration:down

> Roll back migrations for all modules.

Roll back migrations for every module that defines a `bin/migration/down.ts` script. Each module's rollback script is run from its own directory. By default only the most recently applied migration is rolled back; pass `--version` to roll back the single migration with that version.

Each rollback runs the migration's `down()` inside a transaction and removes its row from the `migrations` table, so a later [`migration:up`](/cli/commands/migration-up) re-applies it.

## Usage

```bash theme={null}
talos migration:down [options]
```

## Examples

Roll back the most recently applied migration:

```bash theme={null}
talos migration:down
```

Roll back a specific migration by its version (the timestamp in the `Migration<version>.ts` filename returned by `getVersion()`):

```bash theme={null}
talos migration:down --version=20240101120000
```

## Options

| Option      | Description                                                                                              | Default |
| ----------- | -------------------------------------------------------------------------------------------------------- | ------- |
| `--version` | Version of the migration to roll back. When omitted, the most recently applied migration is rolled back. | latest  |

<Note>
  Rolling back relies on a correct `down()`. If `down()` does not exactly reverse `up()`, prefer adding a new corrective migration over a rollback on shared data.
</Note>

## AI Skill

This command ships a matching `database:migrate` skill. It teaches your AI agent to drive the database lifecycle — applying and rolling back migrations, reseeding, and verifying the schema matches the entities.

<Tabs>
  <Tab title="Claude">
    ```bash theme={null}
    talos claude:init
    ```
  </Tab>

  <Tab title="Codex">
    ```bash theme={null}
    talos codex:init
    ```
  </Tab>
</Tabs>
