Class: Nandi::Instructions::AddIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/nandi/instructions/add_index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fields:, table:, **kwargs) ⇒ AddIndex

Returns a new instance of AddIndex.



6
7
8
9
10
11
12
# 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

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



35
36
37
# File 'lib/nandi/instructions/add_index.rb', line 35

def fields
  @fields
end

#tableObject (readonly)

Returns the value of attribute table.



35
36
37
# File 'lib/nandi/instructions/add_index.rb', line 35

def table
  @table
end

Instance Method Details

#extra_argsObject



18
19
20
21
22
23
24
25
26
27
28
29
# 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

#lockObject



31
32
33
# File 'lib/nandi/instructions/add_index.rb', line 31

def lock
  Nandi::Migration::LockWeights::SHARE
end

#procedureObject



14
15
16
# File 'lib/nandi/instructions/add_index.rb', line 14

def procedure
  :add_index
end