Deploy

Workers

Create a second resource from the same repo — leave it private (the default; over the API send "http": false) — and set a start command:

sh -c "npm run migrate && npm run start:worker"

That overrides the image's CMD. Quoted arguments hold together, so a whole shell line is fine.

Variables expand as you'd expect — sh -c 'psql "$DATABASE_URL" -c "select 1"' gets the resource's own DATABASE_URL (write $$ only when you mean the shell's process id).

Something wrong or missing here? Tell us and a person will answer.