lib/sequel_rails/storage/postgres.rb in sequel-rails-0.9.16 vs lib/sequel_rails/storage/postgres.rb in sequel-rails-0.9.17
- old
+ new
@@ -20,10 +20,11 @@
def _drop
with_pgpassword do
commands = ['dropdb']
add_connection_settings commands
+ add_flag commands, '--if-exists'
commands << database
safe_exec commands
end
end
@@ -62,10 +63,13 @@
rescue Sequel::DatabaseDisconnectError
# Will raise an error as it kills existing process running this
# command. Seems to be only way to ensure *all* test connections
# are closed
nil
+ rescue Sequel::DatabaseConnectionError
+ # Will raise an error if the database doesn't exist.
+ nil
end
def encoding
@encoding ||= config['encoding'] || charset
end
@@ -102,12 +106,12 @@
ensure
ENV['PGPASSWORD'] = nil unless password.blank?
end
def add_connection_settings(commands)
- add_option commands, '--username', username
- add_option commands, '--host', host
- add_option commands, '--port', port.to_s
+ add_option commands, '--username', username unless username.blank?
+ add_option commands, '--host', host unless host.blank?
+ add_option commands, '--port', port.to_s unless port.to_s.blank? || port.to_s == "0"
end
end
end
end