I have a database db
. I want to judge if flask_migrate
has created tables in db
. If not, upgrade db
. There are commands, but no examples about calling migrate
, upgrade
in python script. The test files in flask_migrate
also run commands:
(o, e, s) = run_cmd('python app.py db migrate')
This should do the trick for you.
from flask_migrate import upgrade
@ns.route('/migrate_db')
class Units(Resource):
def get(self):
upgrade(directory=<path_to_migrations_folder>)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.