kcdragon/mongration

View on GitHub
lib/mongration/status.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Mongration

  # @private
  module Status
    extend self

    FileStatus = Struct.new(:status, :migration_id, :migration_name)

    def migrations
      performed_migrations + pending_migrations
    end

    private

    def performed_migrations
      File.migrated.map do |file|
        FileStatus.new('up', file.version, file.name)
      end
    end

    def pending_migrations
      File.pending.map do |file|
        FileStatus.new('down', file.version, file.name)
      end
    end
  end
end