Class: Flydata::Mysql::RedshiftTableAdapter

Inherits:
Object
  • Object
show all
Includes:
Redshift::Util
Defined in:
lib/flydata/command/sync.rb

Constant Summary

Constants included from Redshift::Util

Redshift::Util::MAX_TABLENAME_LENGTH, Redshift::Util::REDSHIFT_RESERVED_WORDS, Redshift::Util::REDSHIFT_RESERVED_WORDS_HASH, Redshift::Util::REDSHIFT_SYSTEM_COLUMNS, Redshift::Util::REDSHIFT_SYSTEM_COLUMNS_HASH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Redshift::Util

#convert_to_valid_name, #is_redshift_reserved_word?

Constructor Details

#initialize(mysql_table) ⇒ RedshiftTableAdapter



760
761
762
763
764
# File 'lib/flydata/command/sync.rb', line 760

def initialize(mysql_table)
  @table_name = convert_to_valid_name(mysql_table.table_name)
  set_columns(mysql_table.columns)
  @primary_keys = mysql_table.primary_keys
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



766
767
768
# File 'lib/flydata/command/sync.rb', line 766

def columns
  @columns
end

#primary_keysObject (readonly)

Returns the value of attribute primary_keys.



766
767
768
# File 'lib/flydata/command/sync.rb', line 766

def primary_keys
  @primary_keys
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



766
767
768
# File 'lib/flydata/command/sync.rb', line 766

def table_name
  @table_name
end

Instance Method Details

#create_table_sqlObject



768
769
770
771
772
773
774
775
776
777
778
779
# File 'lib/flydata/command/sync.rb', line 768

def create_table_sql
  col_def = @columns.inject([]) { |list, (cn, column)|
    list << build_column_def(column)
    list
  }
  if @primary_keys.count > 0
    col_def << "primary key (#{@primary_keys.join(',')})"
  end
  "CREATE TABLE \#{@table_name} (\#{col_def.join(',')});\n"
end