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.



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

def fields
  @fields
end

#tableObject (readonly)

Returns the value of attribute table.



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

def table
  @table
end

Instance Method Details

#extra_argsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/nandi/instructions/add_index.rb', line 18

def extra_args
  {
    # Overridable defaults
    name: name,

    # Overrides and extra options
    **@extra_args,

    # Mandatory values
    algorithm: :concurrently,
    using: :btree,
  }
end

#lockObject



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

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