lib/hanami/cli/commands/db/utils/postgres.rb in hanami-cli-2.0.0.beta2 vs lib/hanami/cli/commands/db/utils/postgres.rb in hanami-cli-2.0.0.beta3

- old
+ new

@@ -1,16 +1,21 @@ # frozen_string_literal: true require "shellwords" +require "open3" require_relative "database" module Hanami module CLI module Commands module DB module Utils class Postgres < Database def create_command + existing_stdout, status = Open3.capture2(cli_env_vars, "psql -t -c '\\l #{escaped_name}'") + + return true if status.success? && existing_stdout.include?(escaped_name) + system(cli_env_vars, "createdb #{escaped_name}") end def drop_command system(cli_env_vars, "dropdb #{escaped_name}")