class Turboquery::TableMover
Attributes
destination[RW]
from_table[RW]
source[RW]
to_table[RW]
Public Class Methods
new(source:, destination:, from_table:, to_table:)
click to toggle source
# File lib/turboquery/table_mover.rb, line 5 def initialize(source:, destination:, from_table:, to_table:) self.source = source self.destination = destination self.from_table = from_table self.to_table = to_table end
Public Instance Methods
move()
click to toggle source
# File lib/turboquery/table_mover.rb, line 12 def move create_destination unless destination_exists? key = copy_source_to_s3 copy_s3_to_destination(key) end
Private Instance Methods
copy_s3_to_destination(key)
click to toggle source
# File lib/turboquery/table_mover.rb, line 39 def copy_s3_to_destination(key) destination.copy_s3_to_table(key, to_table) end
copy_source_to_s3()
click to toggle source
# File lib/turboquery/table_mover.rb, line 35 def copy_source_to_s3 source.copy_table_to_s3(from_table) end
create_destination()
click to toggle source
# File lib/turboquery/table_mover.rb, line 28 def create_destination structure = source.dump_table_ddl(from_table) structure.gsub!(/^CREATE TABLE [^\(]+\(/, "CREATE TABLE #{to_table} (") destination.execute(structure) fail 'Unable to create destination table' unless destination_exists? end
destination_exists?()
click to toggle source
# File lib/turboquery/table_mover.rb, line 24 def destination_exists? destination.table_exists?(to_table) end
source_exists?()
click to toggle source
# File lib/turboquery/table_mover.rb, line 20 def source_exists? source.table_exists?(from_table) end