Add db-migrate executable command to application container PATH
Use consistent method for creating db connection between migrations and application
Remove code for make_connection_uri
Remove support for offline migrations
Context for reviewers
The infra template PR https://github.com/navapbc/template-infra/pull/316/files adds application-requirements that require application container to have a "db-migrate" command available in the PATH. This PR updates template-application-flask to do that.
The previous migrations code connects to the database using a different method than what the application uses, which means that the migrations code does not have the functionality of connecting to the DB using IAM auth, which is a requirement for the infra template. In this change, we make the migrations code in env.py use the existing PostgresDBClient class and remove the extraneous make_connection_uri class.
As part of the change, we also remove support for offline migrations, which is not needed in general. This simplifies the code paths in env.py and reduces maintenance burden.
Testing
Locally ran make release-build then ran docker -it <image hash> db-migrate
The migration obviously didn't succeed since I didn't pass any necessary env vars, but the db-migrate command was found.
Ticket
Resolves #175
Changes
Context for reviewers
The infra template PR https://github.com/navapbc/template-infra/pull/316/files adds application-requirements that require application container to have a "db-migrate" command available in the PATH. This PR updates template-application-flask to do that.
The previous migrations code connects to the database using a different method than what the application uses, which means that the migrations code does not have the functionality of connecting to the DB using IAM auth, which is a requirement for the infra template. In this change, we make the migrations code in env.py use the existing PostgresDBClient class and remove the extraneous make_connection_uri class.
As part of the change, we also remove support for offline migrations, which is not needed in general. This simplifies the code paths in env.py and reduces maintenance burden.
Testing
Locally ran
make release-build
then randocker -it <image hash> db-migrate
The migration obviously didn't succeed since I didn't pass any necessary env vars, but the db-migrate command was found.