Migrations
How to handle migrations with a BYOC app.
Migrations can be added to a BYOC application to run operational scripts, make database schema changes and more.
While Nuon does not enforce how migrations are dispatched for an install, this document outlines several common approaches.
Kubernetes Applications
If your application is using Kubernetes, and you are packaging via Helm you can use a chart hook to execute a migrations script.
For example in your helm chart:
Then, when Nuon installs or upgrades the chart in your install, the hooks will be executed:
Job Components
Job components can be used to run any script within a container image as part of your install. They work just like any other component, and give you access to do powerful things such as run schema migrations, batch jobs and more.
To use job components to manage migrations, first start by adding a container image or docker build component that combines your migration tool, and migrations:
Next, declare a job config that executes your migrations image.
When the job component is released, the script will be executed just like any other component deploy.
This approach can be used with common migration tools including:
You can use an existing application container, and use the job component to run a command such as npm run migrations
or rake db:migrate
depending on your framework.