From e9ed6e18e9991f82af49e014922a1a7dd3b189a9 Mon Sep 17 00:00:00 2001 From: eibanez Date: Wed, 28 Jan 2015 15:54:50 -0700 Subject: [PATCH] Add t_band and other tables if missing (closes #14) --- R/process_input.R | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/R/process_input.R b/R/process_input.R index 76f596f..34a1170 100644 --- a/R/process_input.R +++ b/R/process_input.R @@ -248,13 +248,37 @@ add_extra_tables_input <- function(db) { dbWriteTable(db$con, "table_text", text.table, row.names = FALSE) # Add t_memo_data if it doesn't exist - rplexos_message("Adding t_memo_data") if (!db_has_table(db$con, "t_memo_data")) { + rplexos_message("Adding t_memo_data") memo.table <- data.frame(data_id = integer(0), value = character(0)) dbWriteTable(db$con, "t_memo_data", memo.table, row.names = FALSE) } + # Add t_band if it doesn't exist + if (!db_has_table(db$con, "t_band")) { + rplexos_message("Adding t_band") + band.table <- data.frame(data_id = integer(0), + band_id = integer(0)) + dbWriteTable(db$con, "t_band", band.table, row.names = FALSE) + } + + # Add t_date_from if it doesn't exist + if (!db_has_table(db$con, "t_date_from")) { + rplexos_message("Adding t_date_from") + datefrom.table <- data.frame(data_id = integer(0), + date = character(0)) + dbWriteTable(db$con, "t_date_from", datefrom.table, row.names = FALSE) + } + + # Add t_date_to if it doesn't exist + if (!db_has_table(db$con, "t_date_to")) { + rplexos_message("Adding t_date_to") + dateto.table <- data.frame(data_id = integer(0), + date = character(0)) + dbWriteTable(db$con, "t_date_to", dateto.table, row.names = FALSE) + } + # Add data view sql <- "CREATE VIEW data AS SELECT m.collection, m.parent_class, m.parent_group, m.parent_category, m.parent_name,