Class: Llmemory::Maintenance::SearchTokensBackfill

Inherits:
Object
  • Object
show all
Includes:
Crypto::FieldHelpers
Defined in:
lib/llmemory/maintenance/search_tokens_backfill.rb

Overview

Populates search_tokens (blind index) and procedural name_det for rows written before encrypted keyword search support. In-place UPDATE only.

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Constructor Details

#initialize(cipher: nil, store: nil, dry_run: false, force: false) ⇒ SearchTokensBackfill

Returns a new instance of SearchTokensBackfill.



27
28
29
30
31
32
# File 'lib/llmemory/maintenance/search_tokens_backfill.rb', line 27

def initialize(cipher: nil, store: nil, dry_run: false, force: false)
  @cipher = cipher || Llmemory.build_cipher
  @store = (store || Llmemory.configuration.long_term_store).to_s.to_sym
  @dry_run = dry_run
  @force = force
end

Instance Method Details

#run(user_id: nil) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/llmemory/maintenance/search_tokens_backfill.rb', line 34

def run(user_id: nil)
  case @store
  when :active_record, :activerecord
    run_active_record(user_id: user_id)
  when :postgres
    run_postgres(user_id: user_id)
  else
    raise ConfigurationError,
          "backfill_search_tokens requires long_term_store :active_record or :postgres (got #{@store.inspect})"
  end
end