Method: Sip::Sipper#create_scripts_with_index

Defined in:
lib/sip/sipper.rb

#create_scripts_with_index(dbconf, tableconf, db) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/sip/sipper.rb', line 49

def create_scripts_with_index(dbconf, tableconf, db)
  max = db.get_column_max tableconf['tablename'], tableconf['incremental_index']

  method = (tableconf['method'] == "append" and not @config[:overwrite]) ? :append : :overwrite
  if method == :append and max == tableconf['incremental_index_value']
    log "Ignoring #{dbconf['dbname']}.#{tableconf['tablename']} - already up to date"
  else
    Hive::run_hsql_create_table self, db, tableconf, method
    @slaves.each_with_index { |slavename, index|
      @scripts << create_script(slavename, index, dbconf, tableconf, db, max, method)
    }
    db.close
  end

  # update incremental index value if method in conf is append, regardless of whether or 
  # not this is a forced overwrite
  tableconf['incremental_index_value'] = max if tableconf['method'] == "append"
end