DataDrivenInvestor

empowerment through data, knowledge, and expertise. subscribe to DDIntel at…

Follow publication

Member-only story

How to Migrate Flask-Script to Flask 2.0 CLI in 3 Easy Steps

--

Flask 2.0 was released recently, and got a lot of great improvements, but as you should already know with new versions also come things that become obsolete and deprecated.

If you were managing your dev instance of flask with Flask-Script + Flask Migrate in a nice manage.py file where you had all of your commands such as run, test, coverage and db upgrade, db migrate then you will run into some issues when upgrading.

Step one: Cleaning it up

Flask script is no longer supported so you will not longer be able to do this:

from flask_script import Manager
from myapp import app

manager = Manager(app)

So the first thing you will need to do it to get rid of flask_script, so go ahead and delete the import and the line where you were creating the instance of Manager.

Also remember to delete Flask-Script from your requirements.txt file, because you had it there right?

Then get rid of flask_migrate in manage.py

from flask_migrate import Migrate, MigrateCommandmigrate = Migrate(app, db)
manager.add_command(‘db’, MigrateCommand)

We will do the migrations later through the main app class.

--

--

Written by George Studenko

Software developer and AI enthusiast. Having fun with Computer Vision. Get in touch with me here https://linktr.ee/gnstudenko. Looking for a mentor in tech?

Responses (1)

Write a response