fix: Fix and rename pg_database_url.sh helper script (#2747)

- Fix and rename pg_database_url helper script
- Use single-quote and remove trailing whitespace
This commit is contained in:
Pascal Jufer
2021-08-03 19:26:55 +02:00
committed by GitHub
parent ab54d9c629
commit c37966744f
2 changed files with 3 additions and 3 deletions

View File

@@ -0,0 +1,10 @@
#!/usr/bin/env ruby
require 'uri'
# Let DATABASE_URL env take presedence over individual connection params.
if !ENV['DATABASE_URL'].nil? && ENV['DATABASE_URL'] != ''
uri = URI(ENV['DATABASE_URL'])
puts "export POSTGRES_HOST=#{uri.host} POSTGRES_PORT=#{uri.port} POSTGRES_USERNAME=#{uri.user}"
elsif ENV['POSTGRES_PORT'].nil? || ENV['POSTGRES_PORT'] == ''
puts 'export POSTGRES_PORT=5432'
end