Class: ActiveRecord::ConnectionAdapters::Redshift::SchemaCreation

Inherits:
PostgreSQL::SchemaCreation
  • Object
show all
Defined in:
lib/active_record/connection_adapters/redshift/schema_statements.rb

Constant Summary collapse

ENCODING_TYPES =
%w[RAW BYTEDICT DELTA DELTA32K LZO MOSTLY8 MOSTLY16 MOSTLY32 RUNLENGTH TEXT255 TEXT32K]

Instance Method Summary collapse

Instance Method Details

#add_column_options!(sql, options) ⇒ Object

Support



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/active_record/connection_adapters/redshift/schema_statements.rb', line 27

def add_column_options!(sql, options)
  if options[:distkey]
    sql << ' DISTKEY'
  end

  if options[:sortkey]
    sql << ' SORTKEY'
  end

  if options[:encode]
    sql << " ENCODE #{options[:encode]}"
  end

  super
end

#column_options(o) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/active_record/connection_adapters/redshift/schema_statements.rb', line 7

def column_options(o)
  column_options = super
  column_options[:distkey] = o.distkey
  column_options[:sortkey] = o.sortkey

  if o.encode
    encode = o.encode.to_s.upcase
    if ENCODING_TYPES.include?(encode)
      column_options[:encode] = encode
    else
      raise "Invalid encoding type: #{o.encode}"
    end
  else
    # column_options[:encode] = 'RAW'
  end

  column_options
end