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

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.sqd.dev/feedback

```json
{
  "path": "/en/sdk/squid-sdk/resources/tools/migrations-gen",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# TypeORM migration generation

> Generate Postgres migrations from your Squid SDK schema with sqd codegen — apply schema changes incrementally without dropping your indexed data.

The [`typeorm-migration`](https://github.com/subsquid/squid-sdk/tree/master/typeorm/typeorm-migration) tool is used to generate, apply and revert database migrations. It follows the conventions below.

* The migrations are generated in the `db/migrations` folder.
* The database connection is inferred from the `DB_XXX` environment variables.
* All entities should be exported from `lib/model` commonjs module, i.e. the entity classes must be compiled from TypeScript.

Here are some useful commands:

```bash theme={"system"}
npx squid-typeorm-migration apply # apply pending migrations
```

```bash theme={"system"}
npx squid-typeorm-migration generate # generate the migration for the schema defined in schema.graphql
```

```bash theme={"system"}
rm -r db/migrations # clean the db/migrations folder
```
