How to setup a staging DB from a Fly App

I apologize - this is probably a ridiculously basic question, but I need some help connecting the dots.

I have an app that I’ve deployed to fly, and I have my secrets configured on Fly.io. This is a dev setup so that multiple people outside my local computer network can play/test an application. I will periodically want to reset the data state of the published database.

How do I manually setup the database? I’d like to run the equivalent of mix ecto.setup

I can get into iex in the fly environment - but I can’t run a mix task from the fly environment. The app is already compiled - I’m not even certain how I’d run any task other than to start the app.

I’m sure that this is a solved problem by many - but as this is a hobby project I haven’t been able to put the chunk time in to completely figure out how to do this. Can anyone point me to a tutorial, or point me in the right direction to crack this nut?

You might be able to use logic similar to what’s in release.ex

If you look at the migrate file that fly uses, it runs something like exec ./my_app eval MyApp.Release.migrate. You’d probably add a new MyApp.Release.reset method that you would call manually with exec ./my_app eval MyApp.Release.reset.

From there you should be able to use your Repo to drop the data in each table.

Thanks - I think this is where I get confused.

I believe that I can, without issue, write a reset method that I can place in the release.ex file. Is it really as simple as exec /path/to/app MyApp.Release.reset ?

I’ll definitely give it a shot and see what happens :slight_smile: