# Postgres Database

When developing on the API locally, you'll ofter have to make change to the database. This page describes how to achieve that.

## Create a migration

This will create a file in `migrations/` where you'll be able to put your migration and rollback procedures.

```bash
# The name of the migration should use snake case
npm run db:migration:create -- --name name-of-your-migration
```

## Run migrations

This will run all the migrations in `migrations/`

```bash
npm run db:migrate
```

## Rollback last migration

```bash
npm run db:migrate:undo
```


---

# 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://documentarians.gitbook.io/metadocumentation/master/contributing/developers/postgres-database.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.
