Part-DB-server
Part-DB-server copied to clipboard
Running migrations in k8s-deployed container
Although current documentation contains example on how to run migrations when running Part-DB inside docker, it's not a suitable way to run it inside container deployed in k8s (unless you do some nasty tricks).
In k8s, one should exec into container, and then invoke migrate command using sudo -E -u www-data like this:
sudo -E -u www-data php bin/console doctrine:migrations:migrate
I'm not sure where to add this in the documentation though (maybe add as alternative next to docker install).
Also, I can see that helm-chart uses initContainer as a solution (but this is nowadays considered inferior to using separate K8s Job triggered from Helm hook):
https://github.com/Part-DB/helm-charts/blob/b2514f3ae03f0d4a59047781260672bd01c433ec/charts/part-db/templates/statefulset.yaml#L38-L45
I plan to implement some automatic migration mechanism for the new docker image (https://github.com/Part-DB/Part-DB-server/discussions/562), as this also makes upgrades much easier.
However, as it's possible that these fail, some automatic backup and recovery mechanism is required, which is not that trivial to implement.