Class: Redshifter::Tasks

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/redshifter/tasks.rb

Instance Method Summary collapse

Instance Method Details

#install_tasksObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/redshifter/tasks.rb', line 5

def install_tasks
  namespace :redshifter do
    desc 'Append an extracted table to Redshift'
    task :append, [:table_config_key] => :environment do |_task, args|
      table_config = Redshifter.config.tables[args[:table_config_key]]
      table = Redshifter::Table.new(table_config)
      Redshifter::ExtractAndUpdateRedshiftTable
        .new(table, timestamp_column: 'created_at')
        .run
    end

    desc 'Create or replace an extracted table in Redshift'
    task :replace, [:table_config_key] => :environment do |_task, args|
      table_config = Redshifter.config.tables[args[:table_config_key]]
      table = Redshifter::Table.new(table_config)
      Redshifter::ExtractAndReplaceRedshiftTable.new(table).run
    end

    desc 'Update an extracted table in Redshift'
    task :update, [:table_config_key] => :environment do |_task, args|
      table_config = Redshifter.config.tables[args[:table_config_key]]
      table = Redshifter::Table.new(table_config)
      Redshifter::ExtractAndUpdateRedshiftTable
        .new(table, timestamp_column: 'updated_at')
        .run
    end
  end
end