Forums

Database migration fails although the needed files are there

Hey,

I am running into a problem that when I run the command "Flask db upgrade" inside my flask projects directory I get the error:

Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.

I am running this command within the virtual environment with all the necessary libraries installed inside the correct directory. Could it be that the flask command is executing within the virtual environments directory? I am doing the migration through the Alembic wrapper Flask-Migrate.

I have adjusted my wsgi file to load environment variables and those are being loaded successfully so I do not think it is that but I add that for full disclosure.

Any help or suggestions is much appreciated.

Found the solution by adding the -d flag to flask db upgrade

Glad you got that working!