Sha256: bd9c9a531d617bacbbc0cf8b9bc3820dc8f0e36f9dc13a1c429e2d707ee59753

Contents?: true

Size: 930 Bytes

Versions: 8

Compression:

Stored size: 930 Bytes

Contents

# frozen_string_literal: true

require_relative "../../application"
require_relative "structure/dump"

module Hanami
  module CLI
    module Commands
      module Monolith
        module DB
          class Migrate < Application
            desc "Migrates database"

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

            def call(target: nil, **)
              return true if Dir[File.join(application.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

8 entries across 8 versions & 1 rubygems

Version Path
hanami-cli-2.0.0.alpha8.1 lib/hanami/cli/commands/monolith/db/migrate.rb
hanami-cli-2.0.0.alpha8 lib/hanami/cli/commands/monolith/db/migrate.rb
hanami-cli-2.0.0.alpha7 lib/hanami/cli/commands/monolith/db/migrate.rb
hanami-cli-2.0.0.alpha6.1 lib/hanami/cli/commands/monolith/db/migrate.rb
hanami-cli-2.0.0.alpha6 lib/hanami/cli/commands/monolith/db/migrate.rb
hanami-cli-2.0.0.alpha4 lib/hanami/cli/commands/monolith/db/migrate.rb
hanami-cli-2.0.0.alpha3 lib/hanami/cli/commands/monolith/db/migrate.rb
hanami-cli-2.0.0.alpha2 lib/hanami/cli/commands/monolith/db/migrate.rb