From 30118cdac4a757f0fdc8f1d9af8bb2860490eff2 Mon Sep 17 00:00:00 2001 From: totoro Date: Tue, 14 Apr 2020 10:12:55 +0900 Subject: [PATCH] IMPORTANT CHANGE we made same change as vtm for location of the file. We move the loading of all migrations file from the application to Hayamiki lib --- model/load_dbm.anubis | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+), 0 deletions(-) create mode 100644 model/load_dbm.anubis diff --git a/model/load_dbm.anubis b/model/load_dbm.anubis new file mode 100644 index 0000000..597dc81 --- /dev/null +++ b/model/load_dbm.anubis @@ -0,0 +1,42 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 11/04/2020 + * Time: 12:48 + * © David RENÉ + */ + +read tools/string.anubis +read tools/basis.anubis +read xlib/database/migration_sqlite3.anubis +read xlib/database/migration_common_sqlite3.anubis + +public define Maybe(Migration) + load_dbm + ( + String file_name + ) + = + if (LoadAdm(Migration))load_adm(file_name) is + { + file_not_found then print("File '"+file_name+"' not found.\n\n");failure, + read_error then print("Error reading file '"+file_name+"'.\n\n");failure, + timeout then print("Timeout when loading '"+file_name+"'.\n\n");failure, + file_damaged then print("File '"+file_name+"' is damaged.\n\n");failure, + bad_version(expected,found) then print("Secondary module '"+file_name+"' doesn't have the same\n"+ + " version ("+found+") as primary module ("+expected+").\n\n");failure, + wrong_type(expected,found) then print("Secondary module '"+file_name+"' has different types\n\n");failure, + ok(db_migration) then println("db migration v"+db_migration.version+" module loaded ");success(db_migration) + }. + +public define List(Migration) + all_migrations + ( + String app_dbm_path, + String app_name + ) + = + with files = directory_list(app_dbm_path, app_name+"_dbm_to_v*.adm"), + all_list = map_select((String file_name) |-> load_dbm(app_dbm_path+file_name), files), + merge_sort(all_list, migration_less) +. -- libgit2 0.21.4