move sqlite to s3, mature metadata summary functions

This commit is contained in:
Patrick Schratz 2024-07-22 20:40:47 +02:00
commit d983f391fb
Signed by: pat-s
GPG key ID: 3C6318841EF78925

View file

@ -40,3 +40,25 @@ set_bin_path <- function(r_version_minor, build_for_minor, local_build_root, cod
return(path)
}
add_column_if_not_exists <- function(db_name, table_name, column_name, column_type) {
# Connect to the database
conn <- dbConnect(SQLite(), dbname = db_name)
# Get the list of columns in the table
columns <- dbGetQuery(conn, paste0("PRAGMA table_info(", table_name, ");"))
# Check if the column already exists
column_exists <- any(columns$name == column_name)
# Add the column if it doesn't exist
if (!column_exists) {
dbExecute(conn, paste0("ALTER TABLE ", table_name, " ADD COLUMN ", column_name, " ", column_type, ";"))
message(paste("Column '", column_name, "' added to table '", table_name, "'.", sep = ""))
} else {
message(paste("Column '", column_name, "' already exists in table '", table_name, "'.", sep = ""))
}
# Disconnect from the database
dbDisconnect(conn)
}