class DataMigrate::SchemaDumper
Provides the capability to write the current data schema version to the data_schema file Based on ActiveRecord::SchemaDumper
Public Class Methods
dump(connection = ActiveRecord::Base.connection, stream = STDOUT)
click to toggle source
# File lib/data_migrate/schema_dumper.rb, line 10 def dump(connection = ActiveRecord::Base.connection, stream = STDOUT) new(connection).dump(stream) stream end
new(connection)
click to toggle source
# File lib/data_migrate/schema_dumper.rb, line 30 def initialize(connection) @connection = connection all_versions = DataSchemaMigration.normalized_versions @version = begin all_versions.max rescue StandardError 0 end end
Public Instance Methods
dump(stream)
click to toggle source
# File lib/data_migrate/schema_dumper.rb, line 16 def dump(stream) define_params = @version ? "version: #{@version}" : "" if stream.respond_to?(:external_encoding) && stream.external_encoding stream.puts "# encoding: #{stream.external_encoding.name}" end stream.puts "DataMigrate::Data.define(#{define_params})" stream end