Managing database schema migrations¶
Times Square use Alembic to manage its SQLAlchemy-based relational database. When a new version of Times Square is released that includes database schema changes, you will need to run the procedure described here. Times Square checks if the database schema is consistent with the codebase when it starts up, making it impossible to run the application if the schema is out of date.
Upgrading the database schema¶
If Times Square is running in a production environment, schedule and announce downtime for Times Square.
Set
config.updateSchema
to true in thevalues-environment.yaml
file for thetimes-square
application for this environment:config: updateSchema: true
Push these changes to GitHub on the branch that is deployed to the environment.
Stop the Times Square deployments by deleting the Kubernetes deployment for both the API service and the worker service in Argo CD.
Sync the Times Square application in Argo CD. This takes the follow actions:
The
times-square-schema-update
Kubernetes Job runs as a Helm pre-upgrade hook.The Times Square API and worker deployments are recreated.
In Phalanx, reset the
config.updateSchema
value to false in thevalues-environment.yaml
file for thetimes-square
application for this environment.