Skip to content

database: Validate (but do not migrate) schema on app startup

Warren Gifford requested to merge ef/startup-validation into main

Created by: efritz

This PR breaks the constructor methods in the internal/database/connection/live package to a Migrate/Ensure pair that will run migrations or return an error on an outdated schema (respectively).

All application startup sequences now use the Ensure variant, as we assume that the migrator has been run to success prior to this version of the application being deployed. (Note that we bypass this in dev with a flag in the environment as we don't want to throw a wrench in developer iteration cycles.)

This PR also modifies the startup of the server container to run the migration utility before starting up any application containers (but after starting up Postgres containers). See #28929, merged into this branch.

IMPORTANT: Do not merge this until the migrator has been put in place in Cloud and managed instances, the k8s, docker-compose, and pure docker deployment instructions have been updated, and we have backwards compatibility checks running in CI. Once the migrator exists in deploy-sourcegraph, we should have the cluster-test.sh CI check pass and be able to merge this effort.

Fixes #25261 (closed).

Merge request reports

Loading