Automatically migrate database and schema dump upon deploying to Heroku.
Used 10 times
D
Dale Zak
Usage
Run this command in your Rails app directory in the terminal:
rails app:template LOCATION="https://railsbytes.com/script/zr4spr"
Template Source
Review the code before running this template on your machine.
file 'lib/tasks/db/schema.rake', <<~CODE
Rake::Task["assets:precompile"].enhance do
unless Rails.env.development? || Rails.env.test?
puts "rake db:migrate..."
Rake::Task["db:migrate"].invoke
puts "db:schema:cache:dump..."
Rake::Task["db:schema:cache:dump"].invoke
end
end
CODE