microblog icon indicating copy to clipboard operation
microblog copied to clipboard

INFO [alembic.env] No changes in schema detected.

Open BansheePrime opened this issue 2 years ago • 6 comments

After running: $ flask db migrate -m "users table"

Result is: ... No changes in schema detected.

Checking my env with: $ echo $FLASK*

getting: app app.db config.py microblog.py migrations pycache requirements.txt venv

Somehow reverting to state 4.4 Database Models and removing ./migrations directory doesn't resolve situation.

BansheePrime avatar Feb 11 '22 06:02 BansheePrime

I'm facing the same issue. Finding a fix would be fantastic.

ondiekelijah avatar Feb 11 '22 06:02 ondiekelijah

It's not possible for me to tell you exactly what the problem is, but this error means that Flask-Migrate cannot see your models. So my guess is that you have not imported your models into the application, in the way that is shown in this tutorial. I suggest you compare your code against mine to find the issue. The introduction section of the chapter you are on has a download link for working code for the chapter.

miguelgrinberg avatar Feb 11 '22 09:02 miguelgrinberg

It's not possible for me to tell you exactly what the problem is, but this error means that Flask-Migrate cannot see your models. So my guess is that you have not imported your models into the application, in the way that is shown in this tutorial. I suggest you compare your code against mine to find the issue. The introduction section of the chapter you are on has a download link for working code for the chapter.

You absolutely right. And I'm sure of it because its my second time running project (sorry, my way of learning) and last time there was no issue. I mostly was hoping to catch communal answer like: "Hey, you forgot to check so and so".

BansheePrime avatar Feb 11 '22 12:02 BansheePrime

Hi Miguel, I'm trying to have one module.py per table. I put all such modules in a folder called models, with an __ init __.py which imports each table:

from table_a import TableA
from table_b import TableB

Do you think this can work with flask-migrate? At the moment I have the same issue: No changes in schema detected. Thanks

mokadevcloud avatar Apr 25 '22 12:04 mokadevcloud

@mokadevcloud Yes, this definitely should work, but you have to import the models into the application to be seen by SQLAlchemy and Flask-Migrate. Have you done that?

miguelgrinberg avatar Apr 25 '22 12:04 miguelgrinberg

I don't yet have any routes which return data, for example. But I did import into main.py where I have:

@app.shell_context_processor
def make_shell_context():
    """Export stuff to flask shell."""
    return {
        'db': db,
        'TableA': TableA,
        'TableB': TableB
    }

However, flask-migrate started working for me after one more change: I did export FLASK_APP=main. Thanks for the quick response!

mokadevcloud avatar Apr 25 '22 13:04 mokadevcloud