lib/pg_partition_manager.rb
# Drop the tables that contain data that should be expired based on the
# retention period
Drop the tables that contain data that should be expired based on the
retention period
Drop the tables that contain data that should be expired based on the retention period
def drop_tables
      schema, table = @partition[:parent_table].split(".")
      table_suffix = retention.to_s.tr("-", "_")
      result = @db.exec("select nspname, relname from pg_class c inner join pg_namespace n on n.oid = c.relnamespace where nspname = '#{schema}' and relname like '#{table}_p%' and relkind = 'r' and relname < '#{table}_p#{table_suffix}' order by 1, 2")
      result.map do |row|
        child_table = "#{row["nspname"]}.#{row["relname"]}"
        @db.exec("drop table if exists #{child_table}")
        child_table
      end
    end
def drop_tables schema , table = @partition [ :parent_table ] . split ( "." ) table_suffix = retention . to_s . tr ( "-" , "_" ) result = @db . exec ( "select nspname, relname from pg_class c inner join pg_namespace n on n.oid = c.relnamespace where nspname = '#{schema}' and relname like '#{table}_p%' and relkind = 'r' and relname < '#{table}_p#{table_suffix}' order by 1, 2" ) result . map do | row | child_table = "#{row["nspname"]}.#{row["relname"]}" @db . exec ( "drop table if exists #{child_table}" ) child_table end end
Drop the tables that contain data that should be expired based on the
retention period
Drop the tables that contain data that should be expired based on the retention period