-
I put a question on the pallets discord for this but got no response -- https://discord.com/channels/531221516914917387/531571912619458591/1101567562535424090 After a couple of days scratching my head for louking/mysql-docker#3 I remembered I'd seen it before. My comments at the time were louking/webmodules#26 (comment), pointing at flask-sqlalchemy's version 3.x. Having said that the error happens during flask-migrate, so I'm raising the question here. This seems fairly basic, so I'm not sure what I'm doing wrong. I have a simple model for the default database, and a "users" model a la flask-security-too for the users database, bound via SQLALCHEMY_BINDS. When I try to do the initial migration, there are errors while migrating the default database indicating the software is looking at the users database rather than the default. This happens with https://github.com/louking/mysql-docker/tree/2e1d8b2f6468257fae5268801797cfed82ea3c22 Sorry about the added complexity due to docker. Or maybe stackoverflow is a better place for this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Flask-Migrate is a thin wrapper for Alembic, there is very little database-specific logic. Is there any chance this is actually a problem in your model definitions? It seems you are upgrading both SQLAlchemy and Flask-SQLAlchemy over major versions. Maybe something change there? Have you read the error message that you are getting? It seems to indicate there is a problem with your model definitions. Also, it goes without saying that if you are upgrading SQLAlchemy and Flask-SQLAlchemy you should also upgrade Flask-Migrate and Alembic, regardless of this issue. |
Beta Was this translation helpful? Give feedback.
-
Perhaps this is more a question for flask-sqlalchemy than flask-migrate. I installed all the packages fresh for this project, so I think these were the latest. Here's what I had which didn't work for flask db migrate.
and I needed to replace with the following which works for
I think the model is very simple and unless I really don't understand how binds works, is correct. But see [1]. The users database tables all have bind_key defined. The error message is about the
and the users database has
[1] But looking at the syntax for |
Beta Was this translation helpful? Give feedback.
-
It looks like the Table() definition has changed for binds with flask-sqlalchemy 3.x. Compare https://flask-sqlalchemy.palletsprojects.com/en/2.x/binds/
with https://flask-sqlalchemy.palletsprojects.com/en/3.0.x/binds/
Not sure why it took me pasting my model into this question to consider that possibility. I do need to test this, but will close this question at this point because it seems likely this is resolved. Thanks for listening. |
Beta Was this translation helpful? Give feedback.
It looks like the Table() definition has changed for binds with flask-sqlalchemy 3.x. Compare https://flask-sqlalchemy.palletsprojects.com/en/2.x/binds/
with https://flask-sqlalchemy.palletsprojects.com/en/3.0.x/binds/
Not sure why it took me pasting my model into this question to consider that possibility.
I do need to test this, but will close this question at this point…