Metadata-Version: 2.1
Name: flask-migratepg
Version: 0.0.5
Summary: Simple migration command for Flask and Psycopg 3.
Author-email: Damien Bezborodov <dbezborodov@gmail.com>
Project-URL: Homepage, https://github.com/bezborodow/flask-migratepg
Project-URL: Bug Tracker, https://github.com/bezborodow/flask-migratepg/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Framework :: Flask
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# `flask-migratepg`: Database Migrations for Flask and PostgreSQL with Psycopg

This is a simple migrations tool for Flask and [Psycopg 3](https://www.psycopg.org/psycopg3/).

 1. Install and setup the Flask extension.
 2. Place SQL migrations under `database/migrations/`.
 3. Execute migrations.

Setup in application:

````python
from flask import Flask
from flask_migratepg import MigratePg
import os

app = Flask(__name__)
app.config.from_mapping(
    MIGRATIONS_PATH=os.path.abspath('database/migrations'),
    PSYCOPG_CONNINFO="dbname=example host=localhost user=example password=secret"
)
MigratePg(app)
````

Then to run migrations:

```
flask migrate execute
```

This will run migrations in alphabetical order and track them in a migrations table.

Migrations are placed under `database/migrations/` as either an **SQL** or **Python** file
(that is, with an `.sql` or `.py` filename extension resepectively.)

An SQL migration will simply be executed.

A Python migration can implement a method `migrate(conn)`. If this method is
present, it will be called. An example of this:

````python
def migrate(conn):
    cur = conn.cursor()
    # ...
````
