Class: GDK::Command::TruncateLegacyTables

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/gdk/command/truncate_legacy_tables.rb

Overview

Truncate legacy database tables to remove stale data in the CI decomposed database

Constant Summary collapse

FLAG_FILE =
"#{GDK.root}/.cache/.truncate_tables".freeze

Instance Attribute Summary

Attributes inherited from BaseCommand

#stderr, #stdout

Instance Method Summary collapse

Methods inherited from BaseCommand

#config, #display_help_message, #help, #initialize, #print_help, #print_ready_message, #ready_messages, validate_config?

Constructor Details

This class inherits a constructor from GDK::Command::BaseCommand

Instance Method Details

#run(_args = []) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/gdk/command/truncate_legacy_tables.rb', line 11

def run(_args = [])
  unless truncation_needed?
    GDK::Output.info('Truncation not required as your GDK is up-to-date.')
    return true
  end

  ensure_databases_running
  truncate_tables
  true
end

#truncation_needed?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/gdk/command/truncate_legacy_tables.rb', line 22

def truncation_needed?
  ci_database_enabled? && !geo_secondary? && !flag_file_exists?
end