Class: Arfi::Commands::FIdx

Inherits:
Thor
  • Object
show all
Defined in:
lib/arfi/commands/f_idx.rb

Overview

Arfi::Commands::FIdx module contains commands for manipulating functional index in Rails project.

Instance Method Summary collapse

Instance Method Details

#create(index_name) ⇒ void

This method returns an undefined value.

Arfi::Commands::FIdx#create -> void

This command is used to create the functional index.

Examples:

bundle exec arfi f_idx create some_function

Parameters:

  • index_name (String)

    Name of the index.

Raises:

See Also:

  • #validate_schema_format!


23
24
25
26
27
# File 'lib/arfi/commands/f_idx.rb', line 23

def create(index_name)
  validate_schema_format!
  content = build_sql_function(index_name)
  create_index_file(index_name, content)
end

#destroy(index_name, revision = '01') ⇒ void

This method returns an undefined value.

Arfi::Commands::FIdx#destroy -> void

This command is used to delete the functional index.

Examples:

bundle exec arfi f_idx destroy some_function [revision index (just an integer, 1 is by default)]

Parameters:

  • index_name (String)

    Name of the index.

  • revision (String) (defaults to: '01')

    Revision of the index.

Raises:



40
41
42
43
44
45
46
# File 'lib/arfi/commands/f_idx.rb', line 40

def destroy(index_name, revision = '01')
  validate_schema_format!

  revision = "0#{revision}" if revision.match?(/^\d$/)
  FileUtils.rm("#{functions_dir}/#{index_name}_v#{revision}.sql")
  puts "Deleted: #{functions_dir}/#{index_name}_v#{revision}.sql"
end