Sha256: c9cb6da64d45cc36b5bc41ba78bfc80817b0c72bc6c8c636518ae3d21a914c1e

Contents?: true

Size: 907 Bytes

Versions: 6

Compression:

Stored size: 907 Bytes

Contents

# frozen_string_literal: true

require "hanami/cli"
require "snowpack/cli/application/command"
require_relative "structure/dump"
require_relative "utils/database"

module Snowpack
  module CLI
    module Application
      module Commands
        module DB
          class Version < Command
            desc "Print schema version"

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

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

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

            private

            def database
              @database ||= Utils::Database.for_application(application)
            end
          end
        end

        register "db version", DB::Version
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
snowpack-1.0.0.alpha7 lib/snowpack/cli/application/commands/db/version.rb
snowpack-1.0.0.alpha6 lib/snowpack/cli/application/commands/db/version.rb
snowpack-1.0.0.alpha5 lib/snowpack/cli/application/commands/db/version.rb
snowpack-1.0.0.alpha4 lib/snowpack/cli/application/commands/db/version.rb
snowpack-1.0.0.alpha3 lib/snowpack/cli/application/commands/db/version.rb
snowpack-1.0.0.alpha2 lib/snowpack/cli/application/commands/db/version.rb