Class: Pcrd::Commands::Cleanup

Inherits:
Object
  • Object
show all
Defined in:
lib/pcrd/commands/cleanup.rb

Overview

Drops the replication publication and slot on source, and deletes the local checkpoint database.

Run this after the application has been successfully migrated to the target cluster and you’re confident you won’t need to roll back. The source tables themselves are NOT touched unless –drop-source is passed.

Timeline recommendation:

- Verify the app is healthy on the target cluster
- Wait a few days (or a week) as a rollback window
- Then run `pcrd cleanup`
- Optionally run `pcrd cleanup --drop-source` weeks later

Constant Summary collapse

PASTEL =
Pastel.new

Instance Method Summary collapse

Constructor Details

#initialize(config, options = {}) ⇒ Cleanup

Returns a new instance of Cleanup.



22
23
24
25
# File 'lib/pcrd/commands/cleanup.rb', line 22

def initialize(config, options = {})
  @config  = config
  @options = Options.normalize(options)
end

Instance Method Details

#run(output: $stdout) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pcrd/commands/cleanup.rb', line 27

def run(output: $stdout)
  output.puts
  output.puts PASTEL.bold("Cleanup")
  output.puts PASTEL.dim("" * 60)
  output.puts

  drop_slot_and_pub(output)
  drop_checkpoint(output)
  drop_source_tables(output) if @options[:"drop-source"]

  output.puts
  output.puts "  #{PASTEL.green("")}  Cleanup complete."
  output.puts
end