Sha256: c7eeb13465b8df0343edf984a6d918d987adb590c9d2e50df4b6f273b025f2eb

Contents?: true

Size: 893 Bytes

Versions: 2

Compression:

Stored size: 893 Bytes

Contents

module Hanami
  class CLI
    module Commands
      module Db
        # @since x.x.x
        # @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 x.x.x
          # @api private
          def call(steps:, **)
            context = Context.new(steps: steps.to_int)

            rollback_database(context)
          end

          private

          # @since x.x.x
          # @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

2 entries across 2 versions & 1 rubygems

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