Add a rake task to setup DATABASE_URL for ClearDB
There currently is no other way to inherit environment variables from parent apps on heroku
This commit is contained in:
parent
7d77495936
commit
28eed457b2
1 changed files with 11 additions and 0 deletions
11
lib/tasks/cleardb.rake
Normal file
11
lib/tasks/cleardb.rake
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
namespace :db do
|
||||||
|
desc 'setup DATABASE_URL from CLEARDB_DATABASE_URL in .env'
|
||||||
|
task cleardb_env: :environment do
|
||||||
|
unless ENV['CLEARDB_DATABASE_URL'].nil?
|
||||||
|
cleardb_url = ENV['CLEARDB_DATABASE_URL'].gsub(/^mysql:\/\//, 'mysql2://')
|
||||||
|
dot_env = File.open(Rails.root.join(".env"), 'w')
|
||||||
|
dot_env.puts "DATABASE_URL=\"#{cleardb_url}\""
|
||||||
|
dot_env.close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue