Sha256: dc48d8a95404cd8c9cf07e47d25675418fdaa3a7e44d29cee20bbc6ce4638da4

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module Hanami
  module CLI
    module Commands
      module App
        module DB
          # @api private
          class Create < DB::Command
            desc "Create databases"

            option :gateway, required: false, desc: "Use database for gateway"

            def call(app: false, slice: nil, gateway: nil, command_exit: method(:exit), **)
              exit_codes = []

              databases(app: app, slice: slice, gateway: gateway).each do |database|
                result = database.exec_create_command
                exit_codes << result.exit_code if result.respond_to?(:exit_code)

                if result == true || result.successful?
                  out.puts "=> database #{database.name} created"
                else
                  out.puts "=> failed to create database #{database.name}"
                  out.puts "#{result.err}\n"
                end
              end

              exit_codes.each do |code|
                break command_exit.(code) if code > 0
              end

              re_run_development_command_in_test
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hanami-cli-2.2.1 lib/hanami/cli/commands/app/db/create.rb
hanami-cli-2.2.0 lib/hanami/cli/commands/app/db/create.rb
hanami-cli-2.2.0.rc1 lib/hanami/cli/commands/app/db/create.rb