Sha256: e100b56357e2f8e8e07db8b43daa91f3882ba7c1e7b99dbaaafbc930634b629e

Contents?: true

Size: 873 Bytes

Versions: 2

Compression:

Stored size: 873 Bytes

Contents

# frozen_string_literal: true

module DataMigrate
  ##
  # Provides the capability to write the current data schema version to
  # the data_schema file Based on ActiveRecord::SchemaDumper
  class SchemaDumper
    private_class_method :new

    class << self
      def dump(connection = ActiveRecord::Base.connection, stream = STDOUT)
        new(connection).dump(stream)
        stream
      end
    end

    def dump(stream)
      define_params = @version ? "version: #{@version}" : ""

      stream.puts "DataMigrate::Data.define(#{define_params})"

      stream
    end

    private

    def initialize(connection)
      @connection = connection
      all_versions =  DataSchemaMigration.normalized_versions

      @version = begin
                    all_versions.max
                  rescue StandardError
                    0
                  end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
data_migrate-8.0.0.rc1 lib/data_migrate/schema_dumper.rb
data_migrate-7.0.2 lib/data_migrate/schema_dumper.rb