Class: PgShrink::SubTableFilter

Inherits:
SubTableOperator show all
Defined in:
lib/pg_shrink/sub_table_filter.rb

Instance Attribute Summary

Attributes inherited from SubTableOperator

#database, #parent, #table_name

Instance Method Summary collapse

Methods inherited from SubTableOperator

#default_opts, #initialize, #name, #propagate!, #table, #validate_opts!

Constructor Details

This class inherits a constructor from PgShrink::SubTableOperator

Instance Method Details

#propagate_table!Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pg_shrink/sub_table_filter.rb', line 4

def propagate_table!
  primary_key = @opts[:primary_key]
  foreign_key = @opts[:foreign_key]
  where_clause = @opts[:where]

  self.database.log('Beginning subtable propagation from ' +
           "#{self.parent.table_name} to #{self.table.table_name}")

  self.database.propagate_delete(parent_table: self.parent.table_name,
                                 child_table: self.table.table_name,
                                 parent_key: primary_key,
                                 child_key: foreign_key,
                                 where: where_clause)

  self.database.log('Done with subtable propagation from ' +
           "#{self.parent.table_name} to #{self.table.table_name}")

  if self.table.subtable_filters.any?
    self.database.vacuum_and_reindex!(self.table.table_name)
    self.table.subtable_filters.each(&:propagate_table!)
  end
end