Class: Flydata::SourceMysql::SyncGenerateTableDdl

Inherits:
Flydata::Source::SyncGenerateTableDdl show all
Defined in:
lib/flydata/source_mysql/sync_generate_table_ddl.rb

Instance Attribute Summary

Attributes inherited from Flydata::Source::SyncGenerateTableDdl

#dp

Instance Method Summary collapse

Methods inherited from Flydata::Source::SyncGenerateTableDdl

inherited, #initialize

Methods inherited from Flydata::Source::Component

#initialize

Constructor Details

This class inherits a constructor from Flydata::Source::SyncGenerateTableDdl

Instance Method Details

#generate_flydata_tabledef(tables, options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/flydata/source_mysql/sync_generate_table_ddl.rb', line 19

def generate_flydata_tabledef(tables, options)
  mp = de['mysql_data_entry_preference']
  options = options.merge(mp)
  flydata_tabledefs = []
  error_list = []
  missing_tables = FlydataCore::Mysql::CommandGenerator.each_mysql_tabledef(tables, options) do |mysql_tabledef, error|
    if error
      error_list << error.err_hash
      next
    end
    flydata_tabledefs << mysql_tabledef.to_flydata_tabledef
  end
  if missing_tables
    missing_tables.each {|missing_table| error_list << { error: 'table does not exist in the MySQL database', table: missing_table } }
  end

  [flydata_tabledefs, error_list]
end

#run_compatibility_checkObject



9
10
11
12
13
14
15
16
17
# File 'lib/flydata/source_mysql/sync_generate_table_ddl.rb', line 9

def run_compatibility_check
  MysqlCompatibilityCheck.new(dp, de['mysql_data_entry_preference']).check
  if `which mysqldump`.empty?
    raise "mysqldump is not installed.  mysqldump is required to run the command"
  end
  %w(host username database).each do |conf_name|
    raise "MySQL `#{conf_name}` is neither defined in the data entry nor the local config file" if de['mysql_data_entry_preference'][conf_name].to_s.empty?
  end
end