Sha256: 7264ef2e1a0d6676209dbbc1ee2d1178f124dba6dd9f7d49a9e6b847647219cf

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Hanami
  module CLI
    module Commands
      module App
        module DB
          # @api private
          class Version < DB::Command
            desc "Print schema version"

            option :gateway, required: false, desc: "Use database for gateway"

            # @api private
            def call(app: false, slice: nil, gateway: nil, **)
              databases(app: app, slice: slice, gateway: gateway).each do |database|
                unless database.migrations_dir?
                  relative_migrations_path = database.migrations_path.relative_path_from(database.slice.app.root)
                  out.puts "=> Cannot find version for database #{database.name}: no migrations directory at #{relative_migrations_path}/"
                  return
                end

                migration = database.applied_migrations.last
                version = migration ? File.basename(migration, ".*") : "not available"

                out.puts "=> #{database.name} current schema version is #{version}"
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hanami-cli-2.2.1 lib/hanami/cli/commands/app/db/version.rb
hanami-cli-2.2.0 lib/hanami/cli/commands/app/db/version.rb
hanami-cli-2.2.0.rc1 lib/hanami/cli/commands/app/db/version.rb
hanami-cli-2.2.0.beta2 lib/hanami/cli/commands/app/db/version.rb