1Metadata-Version: 2.1
2Name: Flask-Migrate
3Version: 3.1.0
4Summary: SQLAlchemy database migrations for Flask applications using Alembic.
5Home-page: https://github.com/miguelgrinberg/flask-migrate
6Author: Miguel Grinberg
7Author-email: miguel.grinberg@gmail.com
8License: UNKNOWN
9Project-URL: Bug Tracker, https://github.com/miguelgrinberg/flask-migrate/issues
10Platform: UNKNOWN
11Classifier: Environment :: Web Environment
12Classifier: Intended Audience :: Developers
13Classifier: Programming Language :: Python :: 3
14Classifier: License :: OSI Approved :: MIT License
15Classifier: Operating System :: OS Independent
16Requires-Python: >=3.6
17Description-Content-Type: text/markdown
18License-File: LICENSE
19
20Flask-Migrate
21=============
22
23[![Build status](https://github.com/miguelgrinberg/flask-migrate/workflows/build/badge.svg)](https://github.com/miguelgrinberg/flask-migrate/actions)
24
25Flask-Migrate is an extension that handles SQLAlchemy database migrations for Flask applications using Alembic. The database operations are provided as command-line arguments under the `flask db` command.
26
27Installation
28------------
29
30Install Flask-Migrate with `pip`:
31
32    pip install Flask-Migrate
33
34Example
35-------
36
37This is an example application that handles database migrations through Flask-Migrate:
38
39```python
40from flask import Flask
41from flask_sqlalchemy import SQLAlchemy
42from flask_migrate import Migrate
43
44app = Flask(__name__)
45app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db'
46
47db = SQLAlchemy(app)
48migrate = Migrate(app, db)
49
50class User(db.Model):
51    id = db.Column(db.Integer, primary_key=True)
52    name = db.Column(db.String(128))
53```
54
55With the above application you can create the database or enable migrations if the database already exists with the following command:
56
57    $ flask db init
58
59Note that the `FLASK_APP` environment variable must be set according to the Flask documentation for this command to work. This will add a `migrations` folder to your application. The contents of this folder need to be added to version control along with your other source files.
60
61You can then generate an initial migration:
62
63    $ flask db migrate
64
65The migration script needs to be reviewed and edited, as Alembic currently does not detect every change you make to your models. In particular, Alembic is currently unable to detect indexes. Once finalized, the migration script also needs to be added to version control.
66
67Then you can apply the migration to the database:
68
69    $ flask db upgrade
70
71Then each time the database models change repeat the `migrate` and `upgrade` commands.
72
73To sync the database in another system just refresh the `migrations` folder from source control and run the `upgrade` command.
74
75To see all the commands that are available run this command:
76
77    $ flask db --help
78
79Resources
80---------
81
82- [Documentation](http://flask-migrate.readthedocs.io/en/latest/)
83- [pypi](https://pypi.python.org/pypi/Flask-Migrate)
84- [Change Log](https://github.com/miguelgrinberg/Flask-Migrate/blob/master/CHANGES.md)
85
86
87