Skip to content

Commit

Permalink
Add t_band and other tables if missing (closes #14)
Browse files Browse the repository at this point in the history
  • Loading branch information
eibanez committed Jan 28, 2015
1 parent 757e503 commit e9ed6e1
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion R/process_input.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e9ed6e1

Please sign in to comment.