Class: Pgai::Cli::Enc

Inherits:
Base
  • Object
show all
Defined in:
lib/pgai/cli/enc.rb

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?, #initialize

Constructor Details

This class inherits a constructor from Pgai::Cli::Base

Instance Method Details

#keygenObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/pgai/cli/enc.rb', line 4

def keygen
  encryption_key = build_encryption_key
  key = encryption_key.generate

  say "Generated new encryption key", :green
  say ""

  reference = encryption_key.save(key)

  say ""
  say "✓ Key saved to 1Password", :green
  say "  Reference: #{reference}", :cyan
end

#migrateObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/pgai/cli/enc.rb', line 19

def migrate
  migrator = build_migrator

  unless migrator.migration_needed?
    say "No migration needed. Already using encrypted store.", :green
    return
  end

  say "Starting migration from unencrypted to encrypted store...", :cyan

  result = migrator.migrate

  say ""
  say "✓ Migration complete!", :green
  say "  Migrated #{result[:count]} record types", :cyan
  say "  Legacy store backed up to: #{result[:backup_path]}", :cyan
  say "  Remove it if the migration was successful", :cyan
end