Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview What We Changed #2

Open
wants to merge 10 commits into
base: fork-point
Choose a base branch
from
29 changes: 29 additions & 0 deletions lib/language_pack/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def compile
post_bundler
create_database_yml
install_binaries
run_db_migrate_rake_task
run_assets_precompile_rake_task
end
super
Expand Down Expand Up @@ -743,6 +744,34 @@ def node_js_installed?
@node_js_installed ||= run("#{node_bp_bin_path}/node -v") && $?.success?
end

#
def run_db_migrate_rake_task
instrument 'ruby.run_db_migrate_rake_task' do
dbmigrate = rake.task("db:migrate")
return true unless dbmigrate.is_defined?

require 'benchmark'
if env('DATABASE_URL').nil?
puts "Skipping database migration since DATABASE_URL is not defined."
return
end
ENV['DATABASE_URL'] = env('DATABASE_URL')
ENV['RAILS_ENV'] = env('RAILS_ENV')
ENV['RACK_ENV'] = env('RACK_ENV')
# Segment and shipwire do some questionable validation when started
ENV['SEGMENT_WRITE_KEY'] = env('SEGMENT_WRITE_KEY')
ENV['SHIPWIRE_USERNAME'] = env('SHIPWIRE_USERNAME')
ENV['SHIPWIRE_PASSWORD'] = env('SHIPWIRE_PASSWORD')

topic "Running: rake db:migrate"
time = Benchmark.realtime { pipe("env PATH=$PATH:bin bundle exec rake db:migrate 2>&1") }
if $?.success?
puts "Database migration completed (#{"%.2f" % time}s)"
end

end
end

def run_assets_precompile_rake_task
instrument 'ruby.run_assets_precompile_rake_task' do

Expand Down