# Database commands

> List the schema migrations the platform applied to a deployed project's managed database with helix db migrations, newest first.

`helix db migrations` lists the schema migrations the platform applied to your project's managed database when you deployed, newest first. Use it to see which deployment changed the schema and whether each change was additive or destructive.

## Before you start

The command needs you to be logged in and to have a `projectId` in the config file, which a first `helix deploy` writes for you. It reads the deployed database's history, so the list is empty until a deploy whose source has a `db/schema.ts` has created the database. It does not read the in-memory database that `helix dev` runs.

## helix db migrations

```bash
helix db migrations
helix db migrations --limit 5 --json
```

| Flag | What it does |
|---|---|
| `--limit <n>` | Migrations to list, from 1 to 200. Default 50 |
| `--json` | Print the migrations as JSON instead of a table |
| `--config <path>` | Config file to read the project from, instead of `./helix.config.ts` |

The table has one row per migration, newest first:

| Column | Meaning |
|---|---|
| Applied (UTC) | When the platform applied the migration |
| Deployment ID | The deployment that applied it |
| Migration ID | The migration's identifier |
| Type | `additive` or `destructive` |

With `--json`, each entry carries `appliedAt`, `deploymentId`, `migrationId`, and `classification`.

## Errors

| Message | What to do |
|---|---|
| `No migrations applied yet: no schema has been deployed.` | Deploy a source that has a `db/schema.ts`. The first such deploy creates the database. |
| `projectId is not set in helix.config.ts` | Run `helix deploy` to provision the project, or `helix project set <uuid>` if it already exists. |
| `The platform rejected your session` | Run `helix login` and try again. |
| `You do not have access to project ... database` | Check `projectId` and `workspaceId` in the config file, and use `--config` for a non-default target. |
| `No database for project ...` | The project has no database yet. If you have deployed a schema, check `projectId` in the config file. |
| `The platform failed to read the migrations (HTTP ...)` | Try again shortly. |
| `Invalid --limit value` | Use a whole number between 1 and 200. |

For what the migrations are and how deploys apply them, see [the database guide](/documentation/guides/database/).

---

Canonical: https://helix.tray.ai/documentation/reference/cli/db/
Any link on this page is available as markdown by appending .md to its URL.
Full corpus: https://helix.tray.ai/documentation/llms-full.txt