Sha256: f94eb7d8c0780e364c99b32e6d8a4f6d717d0669169aa63e1bd226e9e1b152c9

Contents?: true

Size: 901 Bytes

Versions: 11

Compression:

Stored size: 901 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 =  DataMigrate::RailsHelper.data_schema_migration.normalized_versions

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
data_migrate-11.2.0 lib/data_migrate/schema_dumper.rb
data_migrate-11.1.0 lib/data_migrate/schema_dumper.rb
data_migrate-11.0.0 lib/data_migrate/schema_dumper.rb
data_migrate-11.0.0.rc3 lib/data_migrate/schema_dumper.rb
data_migrate-11.0.0.rc lib/data_migrate/schema_dumper.rb
data_migrate-9.4.4 lib/data_migrate/schema_dumper.rb
data_migrate-9.4.2 lib/data_migrate/schema_dumper.rb
data_migrate-9.4.1 lib/data_migrate/schema_dumper.rb
data_migrate-9.4.0 lib/data_migrate/schema_dumper.rb
data_migrate-9.3.0 lib/data_migrate/schema_dumper.rb
data_migrate-9.2.0 lib/data_migrate/schema_dumper.rb