Automatic migrations on managed databases.


So I finished setting up my stack, which is a .NET Container running on an app platform with a managed PostgreSQL DB.

I have CI/CD setup with GitHub actions, which pushes an image of my .NET stack to my DO container registry, and the app auto deploys when a new version of it gets pushed.

So far so good.

The thing is my GitHub action also generates a idempotent SQL script which has to be run against my DB before the app gets deployed. The script is stored as an artifact of the build as of now.

I can’t seem to find a way to run the script against my managed DB in DO, I already saw I could add a resource as a job that could be run before the deploy, but it only accepts certain templates and is hard to link with GitHub’s artifacts.

Any idea how I could get around this and could run the script automatically against the DB before the deploy ?

Thanks a lot.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
April 1, 2023

Hi there,

What I personally do is to run my database migrations as part of my run command, that way I make sure that my database schema is up to date right before starting my app.

Here is a quick example:

This is a PHP project, but it should be applicable for other frameworks as well.

Let me know how it goes!



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel