Python – How do I add MigrateCommand when using the cli’s built-in flask?

How do I add MigrateCommand when using the cli’s built-in flask?… here is a solution to the problem.

How do I add MigrateCommand when using the cli’s built-in flask?

Previously, when using Manager in flask_script, we could add commands to Manager like this.

from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager

manager = Manager(app)
manager.add_command('db', MigrateCommand)

Now I’m not using flask scripts in this new flask app, so how do I add the command db to be like flask run?

Solution

The flask db command automatically registers when the extension is installed, and you don’t need to do anything on the application side.

Related Problems and Solutions