flask migrate install code example

Example 1: flask db migrate

flask db init
flask db migrate
flask db upgrade

Example 2: flask migrate install

pip install Flask-Migrate

Example 3: flask migrate

$ flask db migrate -m "Initial migration."

Example 4: flask migrate

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db'

db = SQLAlchemy(app)
migrate = Migrate(app, db)

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(128))