Database Migrate And Schema Dump On Heroku Deploy

Public
Automatically migrate database and schema dump upon deploying to Heroku.
Icons/chart bar
Used 10 times
Created by
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
Comments

Sign up or Login to leave a comment.