Use config/database.yml for ClearDB config

If we use .env heroku neither sees DATABASE_URL nor
config/database.yml and assumes we use postgre. There
also is no need to load the rails env in the task.
This commit is contained in:
Henne Vogelsang 2016-05-25 15:12:30 +02:00
parent 70e82632f2
commit a3dd8e6c95
2 changed files with 5 additions and 6 deletions

View file

@ -1,11 +1,8 @@
namespace :db do
desc 'setup DATABASE_URL from CLEARDB_DATABASE_URL in .env'
task cleardb_env: :environment do
desc 'setup DATABASE_URL from CLEARDB_DATABASE_URL in config/database.yml'
task 'cleardb_env' 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
FileUtils.copy_file('config/database.yml.heroku', 'config/database.yml')
end
end
end