method
indexes
v4.2.1 -
Show latest stable
-
0 notes -
Class: ActiveRecord::SchemaDumper
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0 (0)
- 2.2.1 (0)
- 2.3.8 (0)
- 3.0.0 (0)
- 3.0.9 (0)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (38)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- 7.2.3 (0)
- 8.0.0 (0)
- 8.1.1 (0)
- What's this?
indexes(table, stream)
private
Hide source
# File activerecord/lib/active_record/schema_dumper.rb, line 184 def indexes(table, stream) if (indexes = @connection.indexes(table)).any? add_index_statements = indexes.map do |index| statement_parts = [ "add_index #{remove_prefix_and_suffix(index.table).inspect}", index.columns.inspect, "name: #{index.name.inspect}", ] statement_parts << 'unique: true' if index.unique index_lengths = (index.lengths || []).compact statement_parts << "length: #{Hash[index.columns.zip(index.lengths)].inspect}" if index_lengths.any? index_orders = index.orders || {} statement_parts << "order: #{index.orders.inspect}" if index_orders.any? statement_parts << "where: #{index.where.inspect}" if index.where statement_parts << "using: #{index.using.inspect}" if index.using statement_parts << "type: #{index.type.inspect}" if index.type " #{statement_parts.join(', ')}" end stream.puts add_index_statements.sort.join("\n") stream.puts end end

