Sha256: 3037b6f84b6f1641d7f6ed49ca0a892877ada98b8df5fcb1da5ec61f9d6f852b

Contents?: true

Size: 893 Bytes

Versions: 1

Compression:

Stored size: 893 Bytes

Contents

module Hanami
  class CLI
    module Commands
      module Db
        # @since 1.1.0
        # @api private
        class Rollback < Command
          requires "model.sql"

          desc "Rollback migrations"

          argument :steps, desc: "Number of steps to rollback the database", default: 1

          example [
            "  # Rollbacks latest migration",
            "2 # Rollbacks last two migrations"
          ]

          # @since 1.1.0
          # @api private
          def call(steps:, **)
            context = Context.new(steps: steps.to_int)

            rollback_database(context)
          end

          private

          # @since 1.1.0
          # @api private
          def rollback_database(context)
            require "hanami/model/migrator"
            Hanami::Model::Migrator.rollback(steps: context.steps)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hanami-1.1.0.rc1 lib/hanami/cli/commands/db/rollback.rb