feat: бэкапы локальных баз данных
This commit is contained in:
@@ -40,9 +40,13 @@ check_and_init_scheme = function() {
|
||||
|
||||
cli::cli_inform(c("*" = "проверка схемы..."))
|
||||
|
||||
options(box.path = here::here())
|
||||
box::use(modules/db[local_db_backup])
|
||||
|
||||
options(box.path = config::get("form_app_configure_path"))
|
||||
box::use(configs/enabled_schemes[enabled_schemes])
|
||||
|
||||
# список файлов, изменение которых, приведут к переинициализиации схемы
|
||||
files_to_watch <- c(
|
||||
fs::path(config::get("form_app_configure_path"), "configs", "enabled_schemes.R"),
|
||||
"modules/scheme_generator.R",
|
||||
@@ -53,7 +57,9 @@ check_and_init_scheme = function() {
|
||||
scheme_file <- paste0(config::get("form_app_configure_path"), "/configs/schemas/", scheme_names, ".xlsx")
|
||||
scheme_file <- stats::setNames(scheme_file, scheme_names)
|
||||
|
||||
if (!all(file.exists(scheme_file))) cli::cli_abort(c("Отсутствуют файлы схем для следующих наименований:", paste("-", names(scheme_file)[!file.exists(scheme_file)])))
|
||||
if (!all(file.exists(scheme_file))) {
|
||||
cli::cli_abort(c("Отсутствуют файлы схем для следующих наименований:", paste("-", names(scheme_file)[!file.exists(scheme_file)])))
|
||||
}
|
||||
|
||||
db_files <- paste0(config::get("form_app_configure_path"), "/db/", scheme_names, ".sqlite")
|
||||
|
||||
@@ -71,8 +77,6 @@ check_and_init_scheme = function() {
|
||||
} else {
|
||||
|
||||
saved_hash <- readRDS(hash_file)
|
||||
print(exist_hash)
|
||||
print(saved_hash)
|
||||
|
||||
# если данные были изменены проводим реинициализацию таблицы и схемы
|
||||
if (!all(exist_hash == saved_hash)) {
|
||||
@@ -85,6 +89,13 @@ check_and_init_scheme = function() {
|
||||
}
|
||||
}
|
||||
|
||||
# MAKING BACKUPS
|
||||
if (Sys.getenv("FORM_APP_LOCAL_DB_BACKUP_PATH") != "") {
|
||||
cli::cli_inform(c("*" = "создание бэкапов баз данных..."))
|
||||
purrr::walk(scheme_names, local_db_backup)
|
||||
|
||||
}
|
||||
|
||||
# перезаписываем файл
|
||||
if (!dir.exists("temp")) dir.create("temp")
|
||||
saveRDS(exist_hash, hash_file)
|
||||
|
||||
Reference in New Issue
Block a user