Running Rake Commands
Last updated 02 August 2018
Rake tasks are executed as one-off dynos on Heroku, using the same environment as your app’s dynos. You can run Rake tasks within the remote app environment using the
heroku run rake command as follows:
$ heroku run rake db:version Running `rake db:version` attached to terminal... up, run.1 (in /home/slugs/41913_06f36ef_ab3a/mnt) Current version: 20081118092504
You can pass Rake arguments, run multiple tasks, and pass environment variables just as you would locally. For instance, to migrate the database to a specific version with verbose backtraces:
$ heroku run rake --trace db:migrate VERSION=20081118092504
After running a migration you’ll want to restart your app with
heroku restart to reload the schema and pickup any schema changes.
Not all Rake features are supported on Heroku. The following is a list of known limitations:
Rake tasks that write to disk, such as
rake db:schema:dump, are not compatible with Heroku’s ephemeral filesystem.
db:resettask is not supported. Heroku apps do not have permission to drop and create databases. Use the
heroku pg:resetcommand instead.