I’m migrating our API from heroku to Fly. I dockerized the app and now I need to get the app to run any pending migrations after a new release is deployed.
I saw that you could add something like this
release_command = "yarn run migrate-schema"
in the fly.toml file. Only “issue” is that this app hasn’t been created using a fly.toml file. Is there any way to run that command using
I’m not sure I follow this line. All apps have a fly.toml on them and indeed the block of code you have would be the way to go for migrations.
May I ask how you Dockerized this app so I can help you figure out a good solution for it? (if possible the Dockerfile for it)
Regardless, there’s indeed a way to run commands on you app via flyctl:
fly ssh console -C "your command goes here"
If you don’t have a fly.toml
fly ssh console -a your-app-name -C "your command goes here"
Thanks for the quick reply!
What I mean is that I created the app using
flyctl apps create --app xxxxx --org yyyy and a
fly.toml did not get generated.
By the looks of it, I can just add
fly ssh console -a xxxxxxx -C "yarn run migrate-schema" to my CI after the
flyctl deploy command and migrations should run. Thank you so much for this!
Got it. Usually, the starter command would be
fly launch which generates everything for you.
Since you already have an app you can get the fly.toml by running
fly config save -a your-app-name then feel free to commit it. When you have that toml on the current working directory you don’t need to put
-a app-name on commands anymore
Let me know if this helps
Thank you so much, that makes sense.