Class: Flydata::Source::SyncGenerateTableDdl

Inherits:
Component
  • Object
show all
Defined in:
lib/flydata/source/sync_generate_table_ddl.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, dp, options = {}) ⇒ SyncGenerateTableDdl

Returns a new instance of SyncGenerateTableDdl.


13
14
15
16
# File 'lib/flydata/source/sync_generate_table_ddl.rb', line 13

def initialize(source, dp, options = {})
  super(source, options)
  @dp = dp
end

Instance Attribute Details

#dpObject (readonly)

Returns the value of attribute dp


17
18
19
# File 'lib/flydata/source/sync_generate_table_ddl.rb', line 17

def dp
  @dp
end

Class Method Details

.inherited(child_class) ⇒ Object


9
10
11
# File 'lib/flydata/source/sync_generate_table_ddl.rb', line 9

def self.inherited(child_class)
  Source.register(child_class, self)
end

Instance Method Details

#generate_flydata_tabledef(tables, options) ⇒ Object


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/flydata/source/sync_generate_table_ddl.rb', line 29

def generate_flydata_tabledef(tables, options)
  prefs = data_entry_prefs
  reset_uk_as_pk_override(tables, prefs)
  options = options.merge(prefs)
  flydata_tabledefs = []
  error_list = []
  uk_as_pk_override = {}

  missing_tables = each_source_tabledef(tables, options) do |source_tabledef, error|
    if error
      error_list << error.err_hash
      next
    end

    if source_tabledef.converting_uk_to_pk?
      new_pk_override = source_tabledef.get_pk_override_as_hash
      uk_as_pk_override.merge!(new_pk_override)
    end
    flydata_tabledefs << source_tabledef.to_flydata_tabledef
  end

  if missing_tables
    missing_tables.each {|missing_table| error_list << { error: "Table does not exist in the #{data_source_type_display_name}", table: missing_table } }
  end

  [flydata_tabledefs, error_list, uk_as_pk_override]
end

#run_compatibility_checkObject

Public Interface: Run compatibility check

Run whatever check (compatibility, connectivity, privilege, etc) to ensure that the 'sync:generate_table_ddl' command can run without an issue.

Raises exception when check fails


25
26
27
# File 'lib/flydata/source/sync_generate_table_ddl.rb', line 25

def run_compatibility_check
  raise UnsupportedSourceError,  "subclass must implement"
end