Class: Arfi::Commands::FIdx
- Inherits:
-
Thor
- Object
- Thor
- Arfi::Commands::FIdx
- Defined in:
- lib/arfi/commands/f_idx.rb
Overview
Arfi::Commands::FIdx module contains commands for manipulating functional index in Rails project.
Constant Summary collapse
- ADAPTERS =
i[postgresql mysql].freeze
Instance Method Summary collapse
-
#create(index_name) ⇒ void
Arfi::Commands::FIdx#create -> void.
-
#destroy(index_name) ⇒ void
Arfi::Commands::FIdx#destroy -> void.
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.
ARFI also supports the use of custom templates for SQL functions, but now there are some restrictions and rules according to which it is necessary to describe the function. First, the function must be written in a Ruby-compatible syntax: the file name is not so important, but the name for the function name must be interpolated with the index_name variable name, and the function itself must be placed in the HEREDOC statement. Below is an example file.
To use a custom template, add the –template flag.
57 58 59 60 61 |
# File 'lib/arfi/commands/f_idx.rb', line 57 def create(index_name) validate_schema_format! content = build_sql_function(index_name) create_function_file(index_name, content) end |
#destroy(index_name) ⇒ void
This method returns an undefined value.
Arfi::Commands::FIdx#destroy -> void
This command is used to delete the functional index.
81 82 83 84 85 86 87 88 |
# File 'lib/arfi/commands/f_idx.rb', line 81 def destroy(index_name) validate_schema_format! revision = Integer([:revision] || '01') # steep:ignore NoMethod revision = "0#{revision}" FileUtils.rm("#{functions_dir}/#{index_name}_v#{revision}.sql") puts "Deleted: #{functions_dir}/#{index_name}_v#{revision}.sql" end |