# Database and Migration

### All migrations path

<pre><code>├── node_modules
<strong>├── mail-templates
</strong>├── migrations
│   ├── 1661868238821-usersTable.ts              # Users table
│   ├── 1661868315626-subscriptionsTable.ts      # Subscriptions table
│   ├── 1708974949319-BlogpostTable.ts           # Blogposts table
│   ├── 1709027986137-FileUploadTable.ts         # File upload table
</code></pre>

### Set environnements variables in <mark style="background-color:blue;">.env</mark>

```
TYPEORM_HOST=
TYPEORM_PORT=
TYPEORM_USERNAME=
TYPEORM_PASSWORD=
TYPEORM_DATABASE=
```

### Run the migration

```
npx ts-node ./node_modules/.bin/typeorm  migration:run -d ./datasource.ts
```

### Create a migration

```
npx typeorm migration:create migrations/nameOfTable
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nzoni.app/nest.js/database-and-migration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
