'How can I migrate flask-sqlalchemy multiple databases?
I know multiple databases work on flask-sqlalchemy with __bind_key__.
But I don't know how to migrate those databases on alembic(flask-migrate).
Here's env.py:
from flask import current_app
config.set_main_option('sqlalchemy.url', current_app.config.get('SQLALCHEMY_BINDS')['bind_main'])
target_metadata = {
'bind_main': current_app.extensions['migrate'].db.metadata,
'bind_follower': current_app.extensions['migrate'].db.metadata,
}
How can I set follower db on target_metadata? flask-migrate doesn't care about bind databases.
Thanks.
Solution 1:[1]
To create a multiple database migration repository, add the --multidb argument to the init command:
$ python app.py db init --multidb
For more details please refer to flask-migrate documentation
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Darshan Patel |
