diff options
author | doabit <doinsist@gmail.com> | 2013-03-24 05:09:54 +0800 |
---|---|---|
committer | doabit <doinsist@gmail.com> | 2013-03-24 05:09:54 +0800 |
commit | 8094156728f72d493916e3d3a8c8d90c5f2d79c0 (patch) | |
tree | 4772eec9db0ed9316941aee23fa5dd038587b3f9 /activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | |
parent | 9e8b7d9d5bb3537f113fbda2a1720c5f412fbe62 (diff) | |
download | rails-8094156728f72d493916e3d3a8c8d90c5f2d79c0.tar.gz rails-8094156728f72d493916e3d3a8c8d90c5f2d79c0.tar.bz2 rails-8094156728f72d493916e3d3a8c8d90c5f2d79c0.zip |
Custom index type support with :using.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index b1baf24cb6..1f111a0976 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -432,6 +432,7 @@ module ActiveRecord next if row[:Key_name] == 'PRIMARY' # skip the primary key current_index = row[:Key_name] indexes << IndexDefinition.new(row[:Table], row[:Key_name], row[:Non_unique].to_i == 0, [], []) + indexes.last.using = row[:Index_type].downcase.to_sym end indexes.last.columns << row[:Column_name] @@ -504,6 +505,15 @@ module ActiveRecord rename_column_indexes(table_name, column_name, new_column_name) end + def add_index(table_name, column_name, options = {}) #:nodoc: + if options.is_a?(Hash) && options[:using] + index_name, index_type, index_columns, index_options = add_index_options(table_name, column_name, options) + execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} USING #{options[:using]} ON #{quote_table_name(table_name)} (#{index_columns})#{index_options}" + else + super + end + end + # Maps logical Rails types to MySQL-specific data types. def type_to_sql(type, limit = nil, precision = nil, scale = nil) case type.to_s |