uwcirg / tb-api

1 stars 1 forks source link

Fix Flask-Migrate setup to account for multiple dbs #21

Open pmanko opened 5 years ago

pmanko commented 5 years ago

Summary of issues:

  1. docker-compose.dev.yml had the file system set to read-only for the web container
  2. Flask-Migrate / Alembic configuration struggles with multiple databases, and the sql bind 'mpower' breaks the expected functionality.

To correctly use flask db migrate to autogenerate changes to just the tb-api data model:

  1. created a new, much simpler factory_migrate.py file that I stripped down to only include db-relevant lines
  2. in tbapi_app.py, i imported create_app from this stripped down file
  3. Updated the env.py and script.py.mako files to remove any references to the binds/extra dbs, since that was breaking once I took out the SQLALCHEMY_BINDS section from the app config

There should be a better approach to this setup, but will likely require deeper understanding of Alembic and Flask-Migrate