class Nandi::Instructions::AddIndex
Attributes
fields[R]
table[R]
Public Class Methods
new(fields:, table:, **kwargs)
click to toggle source
# File lib/nandi/instructions/add_index.rb, line 6 def initialize(fields:, table:, **kwargs) @fields = Array(fields) @fields = @fields.first if @fields.one? @table = table @extra_args = kwargs end
Public Instance Methods
extra_args()
click to toggle source
# File lib/nandi/instructions/add_index.rb, line 18 def extra_args { # Overridable defaults name: name, # Overrides and extra options **extra_args_with_default_index_type, # Mandatory values algorithm: :concurrently, } end
lock()
click to toggle source
# File lib/nandi/instructions/add_index.rb, line 31 def lock Nandi::Migration::LockWeights::SHARE end
procedure()
click to toggle source
# File lib/nandi/instructions/add_index.rb, line 14 def procedure :add_index end
Private Instance Methods
extra_args_with_default_index_type()
click to toggle source
# File lib/nandi/instructions/add_index.rb, line 48 def extra_args_with_default_index_type { using: :btree, }.merge(@extra_args) end
field_names()
click to toggle source
# File lib/nandi/instructions/add_index.rb, line 43 def field_names field_names = fields.respond_to?(:map) ? fields.map(&:to_s).join("_") : fields field_names.to_s.scan(/\w+/).join("_") end
name()
click to toggle source
# File lib/nandi/instructions/add_index.rb, line 39 def name :"idx_#{table}_on_#{field_names}" end