I’m moving a simple web + db setup from PR reviews to Preview environments so there is a separate DB for each PR.
On the very first deployment of the environment, I want to copy a DB using a script. Then when a build happens, I run DB migrations. Subsequent pushes would just run the build command again which would run migrations.
What I’m struggling with is how to fit this into Render’s lifecycle. The only hook I have is
afterFirstDeployCommand but that runs after the build and the start command so the migration errors. There’s also no env variable indicating that this is the first deploy so I can’t write a script.
What I’m after is a hook like Heroku’s
postdeploy which I’ve used for this sort of thing in the past. I need to run a script after service creation, but before the build