在project目录下,输入下面的命令
$ flask db upgrade
Runs the upgrade command in the migration file, to apply the migration
在数据库里,能看到一个新的数据库alembic_version
The alembic_version does is that it stores the versions of our database, and is generally an internally use table that we should generally not touch, as it manages all of our migrations and database versions for us.
$ flask db downgrade
Runs the downgrade command in the migration file, to roll back the migration
Adding the completed column to test migration
class Todo(db.Model):
__tablename__ = 'todos'
id = db.Column(db.Integer, primary_key=True)
description = db.Column(db.String(), nullable=False)
completed = db.Column(db.Boolean, nullable=False, default=False)