Skip to content

Commit 3cb27c5

Browse files
committed
Add default_index_type? to the generic schema dumper doesn't have the knowledge about an index type
1 parent 1c968b4 commit 3cb27c5

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

activerecord/lib/active_record/connection_adapters/abstract_adapter.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,10 @@ def combine_bind_parameters(
509509
result
510510
end
511511

512+
def default_index_type?(index) # :nodoc:
513+
index.using.nil?
514+
end
515+
512516
private
513517

514518
def initialize_type_map(m)

activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,10 @@ def valid_type?(type)
651651
!native_database_types[type].nil?
652652
end
653653

654+
def default_index_type?(index) # :nodoc:
655+
index.using == :btree || super
656+
end
657+
654658
private
655659

656660
def initialize_type_map(m)

activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@ def postgresql_version
402402
@connection.server_version
403403
end
404404

405+
def default_index_type?(index) # :nodoc:
406+
index.using == :btree || super
407+
end
408+
405409
private
406410

407411
# See http://www.postgresql.org/docs/current/static/errcodes-appendix.html

activerecord/lib/active_record/schema_dumper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def index_parts(index)
188188
index_parts << "length: { #{format_options(index.lengths)} }" if index.lengths.present?
189189
index_parts << "order: { #{format_options(index.orders)} }" if index.orders.present?
190190
index_parts << "where: #{index.where.inspect}" if index.where
191-
index_parts << "using: #{index.using.inspect}" if index.using && index.using != :btree
191+
index_parts << "using: #{index.using.inspect}" if !@connection.default_index_type?(index)
192192
index_parts << "type: #{index.type.inspect}" if index.type
193193
index_parts << "comment: #{index.comment.inspect}" if index.comment
194194
index_parts

0 commit comments

Comments
 (0)