Migrations - Flask-Migrate (2)

在project的目录下,输入下面命令:

$ flask db init

Create initial migrations directory structure.
就能看到,在project目录下,多了一个migrations文件夹,文件夹里有alembic.ini文件。


还是在project的目录下,输入下面命令:

$ dropdb database_name
$ createdb database_name
$ flask db migrate

Detects the model changes to be made, and creates a migration file with upgrade and downgrade logic set up. (replaces use of db.create_all())
之后就能看到,在migrations文件夹下,有一个versions文件夹,里面有一个python文件。就能看到upgrade 和 downgrade的函数。

Guess you like

Origin blog.csdn.net/BSCHN123/article/details/121397915