Sha256: fd55f12a2f958136c668dd9e5f1fc080903ceaff6b40cfc23bc4738113541f27

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module Hanami
  module CLI
    module Commands
      module App
        module Generate
          # @since 2.2.0
          # @api private
          class Migration < Command
            argument :name, required: true, desc: "Migration name"
            option :gateway, desc: "Generate migration for gateway"

            example [
              %(create_posts),
              %(add_published_at_to_posts),
              %(create_users --slice=admin),
              %(create_comments --slice=admin --gateway=extra),
            ]

            def generator_class
              Generators::App::Migration
            end

            def call(name:, slice: nil, gateway: nil)
              if slice
                generator.call(
                  key: name,
                  namespace: slice,
                  base_path: fs.join("slices", inflector.underscore(slice)),
                  gateway: gateway
                )
              else
                generator.call(
                  key: name,
                  namespace: app.namespace,
                  base_path: "app",
                  gateway: gateway
                )
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hanami-cli-2.2.1 lib/hanami/cli/commands/app/generate/migration.rb
hanami-cli-2.2.0 lib/hanami/cli/commands/app/generate/migration.rb
hanami-cli-2.2.0.rc1 lib/hanami/cli/commands/app/generate/migration.rb
hanami-cli-2.2.0.beta2 lib/hanami/cli/commands/app/generate/migration.rb