# Flask-Migrate

```bash
pip install Flask-Migrate
```

Migrations are handle by `flask-migrate/alembic`

Creates folder for migrations

## Setup

```python
# extensions.py
from flask_migrate import Migrate

migrate = Migrate()

# app.py
from app.extensions import migrate

#......
migrate.init_app(app, db)
```

Then run this to create the db tables

```bash
flask db init
flask db migrate -m "Message goes here I think"
flask db upgrade
```

## Generate New Migration Files

```bash
flask db migrate -m "Message goes here I think"
flask db upgrade
```


---

# 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://openai.gitbook.io/code-cheatsheets/all/python/flask/postgres/migrate.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.
