Class: Chicago::Database::RedshiftStrategy Private

Inherits:
ConcreteSchemaStrategy show all
Defined in:
lib/chicago/database/concrete_schema_strategies.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Redshift-specific database schema strategy

Instance Method Summary collapse

Methods inherited from ConcreteSchemaStrategy

for_db, #integer_type, #string_type, #table_options

Instance Method Details

#column_hash(column) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



130
131
132
133
134
135
136
137
138
139
140
# File 'lib/chicago/database/concrete_schema_strategies.rb', line 130

def column_hash(column)
  hsh = super(column)
  hsh.delete(:unsigned)
  if column.column_type == :string && hsh[:size]
    # Redshift column sizes are in bytes, not characters, so
    # increase to 4 bytes per-char for UTF-8 reasons.
    hsh[:size] *= 4
  end

  hsh
end

#db_type(column) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



142
143
144
145
146
147
148
149
150
151
# File 'lib/chicago/database/concrete_schema_strategies.rb', line 142

def db_type(column)
  t = super(column)

  case t
  when :year then :smallint
  when :binary then :varchar
  else
    t
  end
end

#id_columnObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



122
123
124
125
126
127
128
# File 'lib/chicago/database/concrete_schema_strategies.rb', line 122

def id_column
  {
    :name => :id,
    :column_type => :integer,
    :unsigned => false
  }
end

#in_numeric_range?(min, max, unsigned_limit) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Redshift does not support unsigned Integers

Returns:

  • (Boolean)


159
160
161
# File 'lib/chicago/database/concrete_schema_strategies.rb', line 159

def in_numeric_range?(min, max, unsigned_limit)
  in_signed_limit?(min, max, unsigned_limit)
end

#indexes(table) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Redshift does not support indexes, so do not output any.



154
155
156
# File 'lib/chicago/database/concrete_schema_strategies.rb', line 154

def indexes(table)
  []
end

#migration_optionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



118
119
120
# File 'lib/chicago/database/concrete_schema_strategies.rb', line 118

def migration_options
  {:separate_alter_table_statements => true, :immutable_columns => true}
end