db_create_new_schema.R 681 B

1234567891011121314151617181920212223
  1. #' Create the new schema
  2. #'
  3. #' Loome andmebaasi uue schema.
  4. #' @param conf list List of configuration data. Rewrite it.
  5. #' @keywords database, schema
  6. #' @export
  7. #' @examples
  8. #' config <- get_config()
  9. #' db_create_new_schema(conf = config)
  10. db_create_new_schema <- function(conf) {
  11. if (!ruut::db_is_shema_exist(conf$schema)) {
  12. conn <- ruut::db_connect()
  13. DBI::dbExecute(conn, sprintf(
  14. "-- DROP SCHEMA x_matsalu;
  15. CREATE SCHEMA %s AUTHORIZATION %s;", conf$schema, conf$user
  16. ))
  17. # Disconnect
  18. lapply(DBI::dbListConnections(RPostgreSQL::PostgreSQL()), DBI::dbDisconnect)
  19. }
  20. }
  21. # conf <- ruut::get_config()
  22. # conf$schema <- "x_valga"
  23. # db_create_new_schema(conf)