Sha256: 5934eccb4ed1c04dd57a8ff1653e4837f262020ec218e1248326bc504abef2b7

Contents?: true

Size: 1.08 KB

Versions: 18

Compression:

Stored size: 1.08 KB

Contents

module Hanami
  class CLI
    module Commands
      module Generate
        # @since 1.1.0
        # @api private
        class Migration < Command
          requires "environment"
          desc "Generate a migration"

          argument :migration, required: true, desc: "The migration name (eg. `create_users`)"

          example [
            "create_users # Generate `db/migrations/#{Project.migration_timestamp}_create_users.rb`"
          ]

          # @since 1.1.0
          # @api private
          def call(migration:, **options)
            migration = Utils::String.underscore(migration)
            context   = Context.new(migration: migration, options: options)

            generate_migration(context)
          end

          private

          # @since 1.1.0
          # @api private
          def generate_migration(context)
            source      = templates.find("migration.erb")
            destination = project.migration(context)

            generate_file(source, destination, context)
            say(:create, destination)
          end
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
hanami-1.3.5 lib/hanami/cli/commands/generate/migration.rb
hanami-1.3.4 lib/hanami/cli/commands/generate/migration.rb
hanami-1.3.3 lib/hanami/cli/commands/generate/migration.rb
hanami-1.3.2 lib/hanami/cli/commands/generate/migration.rb
hanami-1.3.1 lib/hanami/cli/commands/generate/migration.rb
hanami-1.3.0 lib/hanami/cli/commands/generate/migration.rb
hanami-1.3.0.beta1 lib/hanami/cli/commands/generate/migration.rb
hanami-1.2.0 lib/hanami/cli/commands/generate/migration.rb
hanami-1.2.0.rc2 lib/hanami/cli/commands/generate/migration.rb
hanami-1.2.0.rc1 lib/hanami/cli/commands/generate/migration.rb
hanami-1.2.0.beta2 lib/hanami/cli/commands/generate/migration.rb
hanami-1.2.0.beta1 lib/hanami/cli/commands/generate/migration.rb
hanami-1.1.1 lib/hanami/cli/commands/generate/migration.rb
hanami-1.1.0 lib/hanami/cli/commands/generate/migration.rb
hanami-1.1.0.rc1 lib/hanami/cli/commands/generate/migration.rb
hanami-1.1.0.beta3 lib/hanami/cli/commands/generate/migration.rb
hanami-1.1.0.beta2 lib/hanami/cli/commands/generate/migration.rb
hanami-1.1.0.beta1 lib/hanami/cli/commands/generate/migration.rb