Module: ActiveRecord::Mysql::Comment::SchemaStatements

Included in:
ConnectionAdapters::AbstractMysqlAdapter
Defined in:
lib/activerecord-mysql-comment/active_record/connection_adapters/abstract_mysql_adapter.rb

Instance Method Summary collapse

Instance Method Details

#add_index_options(table_name, column_name, options = {}) ⇒ Object



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

def add_index_options(table_name, column_name, options = {})
  if options.key?(:comment)
    comment = options[:comment]
    options.delete(:comment)
  end

  index_name, index_type, index_columns, index_options, algorithm, using = super

  if comment.present?
    if index_options
      index_options << " COMMENT '#{comment}'"
    else
      index_options = " COMMENT '#{comment}'"
    end
  end

  [index_name, index_type, index_columns, index_options, algorithm, using]
end