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.updateSchemato true in thevalues-environment.yamlfile for thetimes-squareapplication for this environment:applications/times-square/values-{environment}.yaml¶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-updateKubernetes Job runs as a Helm pre-upgrade hook.The Times Square API and worker deployments are recreated.
In Phalanx, reset the
config.updateSchemavalue to false in thevalues-environment.yamlfile for thetimes-squareapplication for this environment.