OMOP/R/downloadCurrentDdl.R

33 lines
1.3 KiB
R
Raw Normal View History

#' Get current DDL sitting on the master branch
#'
#' @details
#' This function gets the current ddl on the CDM master branch. It will be taken from the Sql Server folder.
#' The default location is
#' \code{inst/settings/currentOmopDdl.sql}.
#'
#' @param githubPath The path for the GitHub repo containing the package (e.g. 'OHDSI/CommonDataModel').
#' @param pathToCsv The path for the snapshot inside the package.
#' @param outputFile The path where the file should be saved.
#'
#' @examples
#' \dontrun{
#' downloadCurrentDdl("OHDSI/CommonDataModel",
#' pathToCsv="Sql%20Server/OMOP%20CDM%20sql%20server%20ddl.txt")
#' }
Add unit tests for all databases and DDLs (#431) * Add github actions workflow to build package and run tests. * update Description file * rename .Rproj file. * Consolidate 'create' functions into one file. * Add tests for create functions. * update description * removed spaces in file and folder names. Regenerated ddl output. Tried to fix Field_Level.csv file. * consolidate write functions into one file. Add execute function. * update docs * add tests for write and execute functions * update documentation * Add windows and linux runners in github actions. * update github actions * download drivers before running tests * fix small error in setup test file. * debug github actions * debug github actions * debug github actions * debug github actions * fix tiny bug * comment out execute ddl test * fix bug in test * Add execute test back in * revert accidental change in description * add print statement for debugging schema error on github actions. * Fix schema environment variable name * Add comment to github actions workflow file. * remove placeholder text in function documentation. * Rename createdDdl.R to createDdl.R * Hack-a-thon updates Closes #81, #387, #239, #412, #391, #330, #408, #365, #306, #264 * Changed bigint to integer for consistency * Updated DDLs * Add tests for redshift. Clean up test setup file. * Foreign key fixes * Add imports and update docs. * Fix bug in setup test script. * update setup file * Add tests for oracle and sql server. Move setup.R file. * fix bug in setup * debug tests on github * debug github actions * debug actions. * debug actions * debug actions. * Add missing secrets to yaml!! * debug actions * test connection on all platforms * add ddl execution * add windows and linux runners Co-authored-by: Adam Black <adam.black@odysseusinc.com> Co-authored-by: Clair Blacketer <mblacke@its.jnj.com>
2021-08-20 11:59:29 +00:00
#' @importFrom utils download.file
#' @export
downloadCurrentDdl <- function(githubPath="OHDSI/CommonDataModel",
pathToCsv="Sql%20Server/OMOP%20CDM%20sql%20server%20ddl.txt",
outputFile = paste0("inst/sql/sql_server/OMOP CDM ddl ",Sys.Date(),".sql")){
parts <- strsplit(githubPath, "/")[[1]]
if (length(parts) > 2) {
githubPath <- paste(c(parts[1:2], "master", parts[3:length(parts)]), collapse = "/")
} else {
githubPath <- paste(c(parts[1:2], "master"), collapse = "/")
}
url <- paste(c("https://raw.githubusercontent.com", githubPath, pathToCsv), collapse = "/")
download.file(url, destfile = outputFile)
}