Skip to contents

Build the admin table as it was at a point in the past

Usage

cdr_reconstruct_past_tbl(
  as_of = lubridate::now() - lubridate::weeks(x = 4),
  conn_pool,
  db_tbl_name,
  chg_log_suffix = "_DELTAS",
  key_field = "UID",
  ...
)

Arguments

as_of

datetime object in the past, e.g. lubridate::now()-lubridate::weeks(4)

conn_pool

pool or DBI connection

db_tbl_name

primary table name

chg_log_suffix

your table name extension specifying the corresponding change-log table, e.g. '_deltas'

key_field

column in the primary table that acts as the unique row identifier

...

other connection parameters like schema = public

Value

list with primary and change-log tables reconstructed as they were at a time in the past

Examples

if (FALSE) {
conn_pool <- pool::dbPool(
  DBI::dbConnect( drv = RPostgreSQL::PostgreSQL(),
                  dbname = "test",
                  host = "localhost",
                  port = "5432",
                  user = Sys.getenv('postgres_username'),
                  password = Sys.getenv('postgres_password'))
)
cdr_reconstruct_past_tbl(conn_pool = conn_pool, db_tbl_name = 'mtcars', schema = "test")
cdr_reconstruct_past_tbl(conn_pool = conn_pool, db_tbl_name = 'mtcars', schema = "test")
pool::poolClose(conn_pool)
}