flask migrate
时间: 2023-10-09 16:15:33 浏览: 43
Flask-Migrate is a Flask extension that handles database migrations for Flask applications using SQLAlchemy. It allows you to manage changes to your database schema and apply those changes to the database.
To use Flask-Migrate, you first need to install it by running:
```
pip install Flask-Migrate
```
Once installed, you can initialize migrations in your Flask application by running the following command:
```
flask db init
```
This will create a `migrations` directory in your application folder, where all the migration scripts will be stored.
To create a new migration script, you can use the following command:
```
flask db migrate -m "description"
```
Replace "description" with a brief description of the changes you're making. This command will generate a new migration script based on the changes detected in your models.
To apply the migrations to the database, you need to run the following command:
```
flask db upgrade
```
This will apply any pending migrations to the database.
You can find more information about Flask-Migrate in the official documentation: https://flask-migrate.readthedocs.io/