app/models/myreplicator/export.rb in myreplicator-1.0.6 vs app/models/myreplicator/export.rb in myreplicator-1.1.0

- old
+ new

@@ -42,19 +42,29 @@ export_obj.export end ## # Runs the export process using the required Exporter library - ## - def export - Log.run(:job_type => "export", :name => schedule_name, + ## + def export + Log.run(:job_type => "export", :name => schedule_name, :file => filename, :export_id => id) do |log| exporter = MysqlExporter.new exporter.export_table self # pass current object to exporter end end + + # def source_mysql_schema + # sql = "describe #{source_schema}.#{table_name}" + # result = exec_on_source(sql) + # return result + # end + # def destination_schema_mysql + + # end + def export_type? if state == "new" return :new elsif incremental_export? return :incremental @@ -75,12 +85,20 @@ def max_value sql = SqlCommands.max_value_sql(:incremental_col => self.incremental_column, :db => self.source_schema, :table => self.table_name) result = exec_on_source(sql) - - return result.first.first.to_s(:db) + if result.first.nil? + return "" + else + case result.first.first.class.to_s + when "Symbol", "Fixnum" + return result.first.first.to_s + else + return result.first.first.to_s(:db) + end + end end def update_max_val(max_val = nil) if max_val.nil? self.max_incremental_value = max_value @@ -108,11 +126,11 @@ ## # Connects to the server via ssh/sftp ## def connection_factory type config = Myreplicator.configs[self.source_schema] - + case type when :ssh if config.has_key? "ssh_password" return Net::SSH.start(config["ssh_host"], config["ssh_user"], :password => config["ssh_password"]) @@ -207,10 +225,10 @@ # Inner Class that connects to the source database # Handles connecting to multiple databases ## class SourceDb < ActiveRecord::Base - + def self.connect db establish_connection(ActiveRecord::Base.configurations[db]) end ##