Class: Flydata::Mysql::RedshiftTableAdapter
- Inherits:
-
Object
- Object
- Flydata::Mysql::RedshiftTableAdapter
- 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
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#primary_keys ⇒ Object
readonly
Returns the value of attribute primary_keys.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
- #create_table_sql ⇒ Object
-
#initialize(mysql_table) ⇒ RedshiftTableAdapter
constructor
A new instance of RedshiftTableAdapter.
Methods included from Redshift::Util
#convert_to_valid_name, #is_redshift_reserved_word?
Constructor Details
#initialize(mysql_table) ⇒ RedshiftTableAdapter
Returns a new instance of RedshiftTableAdapter.
721 722 723 724 725 |
# File 'lib/flydata/command/sync.rb', line 721 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
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
727 728 729 |
# File 'lib/flydata/command/sync.rb', line 727 def columns @columns end |
#primary_keys ⇒ Object (readonly)
Returns the value of attribute primary_keys.
727 728 729 |
# File 'lib/flydata/command/sync.rb', line 727 def primary_keys @primary_keys end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
727 728 729 |
# File 'lib/flydata/command/sync.rb', line 727 def table_name @table_name end |
Instance Method Details
#create_table_sql ⇒ Object
729 730 731 732 733 734 735 736 737 738 739 740 |
# File 'lib/flydata/command/sync.rb', line 729 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 <<EOT CREATE TABLE #{@table_name} (#{col_def.join(',')}); EOT end |