class Utf8mb4rails::Migrator::ColumnInfo
Abstraction for dealing with column information received from the database
Constants
- TEXT_TYPES
Attributes
info[R]
Public Class Methods
new(info)
click to toggle source
Receives a hash with (:type, :default, :max_length, :charset)
# File lib/utf8mb4rails/migrator/column_info.rb, line 11 def initialize(info) @info = info end
Public Instance Methods
default_value_for_sql()
click to toggle source
@return String : the sql part of the default value of the column definition
# File lib/utf8mb4rails/migrator/column_info.rb, line 29 def default_value_for_sql info_default = info[:default] return nil unless info_default "default '#{info_default}'" end
new_type_for_sql()
click to toggle source
@return String : the sql part of the new type of the column definition
# File lib/utf8mb4rails/migrator/column_info.rb, line 21 def new_type_for_sql info_type = info[:type] return "#{info_type}(#{info[:max_length]})" if info_type =~ /CHAR/ info_type end
text_column?()
click to toggle source
@return Bool : True if the column is of a text type
# File lib/utf8mb4rails/migrator/column_info.rb, line 37 def text_column? TEXT_TYPES.include?(info[:type]) end
utf8mb4?()
click to toggle source
@return Bool : True if the column is in utf8mb4
# File lib/utf8mb4rails/migrator/column_info.rb, line 16 def utf8mb4? info[:charset] =~ /utf8mb4/ end