We are in the process of deploying a new project on Qovery, and we are questioning our usual database migration process.
We used to have a separate script to launch the migration, script that we can reproduce as a Lifecycle Job on Qovery, at the start of each deployment. However, that would require to create a new Docker image to run our migration. Not impossible nor too complex, but still an extra image to maintain.
Hence, we had another idea: what about launching all the migrations when our app starts? Our migrations are built to be compatible with both the current and the new versions, so it shouldn’t break it anyway.
This idea would remove an extra Dockerfile, while simplifying our code base. No need to execute a migration in our integration tests for instance: they would be played automatically when we run our test server.
Are there any drawbacks that we are missing with this approach? It would be interesting to hear other Engineers’ opinions about the process.
Assuming we are using Lifecycle Jobs to handle our migrations, how could we identify if we should play the up or down migration? If it’s a rollback, we would indeed like to rollback the database to its previous state. But from my understanding, it will just be another deployment on Qovery, right?
Thanks for the reply. Our Node application is using node-pg-migrate to handle our migrations.
We generate migration files, with both an up and a down methods. The up version allows to migrate the database to the new state, while the down one restore the database at his previous version.
However, this is true that having only the up should be fine. Especially as our code is compatible with both versions, which is a strong requirement due to the deployment process.
For the probe, thanks for the link. This is super useful to understand the difference between readiness and liveliness probes.
I think we’ll use a separate stage ran before our app, following your message.