Sha256: be4c9f189684b49e201b7b585f7619b443028f3e7ae7b6948844288d041ad331

Contents?: true

Size: 918 Bytes

Versions: 5

Compression:

Stored size: 918 Bytes

Contents

# frozen_string_literal: true

require_relative "../../app/command"
require_relative "structure/dump"

module Hanami
  module CLI
    module Commands
      module App
        module DB
          class Migrate < App::Command
            desc "Migrates database"

            option :target, desc: "Target migration number", aliases: ["-t"]

            def call(target: nil, **)
              return true if Dir[File.join(app.root, "db/migrate/*.rb")].empty?

              measure "database #{database.name} migrated" do
                if target
                  run_migrations(target: Integer(target))
                else
                  run_migrations
                end

                true
              end
            end

            private

            def run_migrations(**options)
              database.run_migrations(**options)
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hanami-cli-2.0.0.rc1 lib/hanami/cli/commands/app/db/migrate.rb
hanami-cli-2.0.0.beta4 lib/hanami/cli/commands/app/db/migrate.rb
hanami-cli-2.0.0.beta3 lib/hanami/cli/commands/app/db/migrate.rb
hanami-cli-2.0.0.beta2 lib/hanami/cli/commands/app/db/migrate.rb
hanami-cli-2.0.0.beta1 lib/hanami/cli/commands/app/db/migrate.rb