How to run database migrations?

I didn’t find documentation on this and most of the discussions on this topic are quite old and refer to Qovery v1.

I see the option to run them manually but it means we would need to expose the database to the external network. We also could hook up migrations to the application startup script but it adds to startup time and might create conflicts when multiple pods start running at the same time. What is the recommended way to run database migrations on Qovery?

Hi @prki ,

I have 3 options to suggest:

Automatic update (Recommend)

The best option is to use a migration schema lib (E.g Flyway, or with an ORM like Prisma for JS) that will handle the upgrade of your DB schema for you. It’s versioned and works in a concurrent environment (E.g with multiple instances running).

Manual via Qovery CLI

You can use the command qovery shell to connect to your pod and run a directly from your instance a migration process. For instance, it’s very common among RAILS users. (Even not recommended at all)

Manual via exposing your DB (not recommended)

As you suggested, you can make your DB publicly accessible and connect to it to run your migration process. I do not recommend this approach but it can be done temporarily.

One tool that you can consider to use for a manual migration is Replibyte