navapbc / template-application-flask

Apache License 2.0
9 stars 4 forks source link

Add db-migrate to container path to meet infra template requirements #176

Closed lorenyu closed 1 year ago

lorenyu commented 1 year ago

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 ran docker -it <image hash> db-migrate

image

The migration obviously didn't succeed since I didn't pass any necessary env vars, but the db-migrate command was found.