Commit 30118cdac4a757f0fdc8f1d9af8bb2860490eff2

Authored by David RENÉ
1 parent 6df1914c

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
Showing 1 changed file with 42 additions and 0 deletions   Show diff stats
model/load_dbm.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 11/04/2020
  5 + * Time: 12:48
  6 + * © David RENÉ
  7 + */
  8 +
  9 +read tools/string.anubis
  10 +read tools/basis.anubis
  11 +read xlib/database/migration_sqlite3.anubis
  12 +read xlib/database/migration_common_sqlite3.anubis
  13 +
  14 +public define Maybe(Migration)
  15 + load_dbm
  16 + (
  17 + String file_name
  18 + )
  19 + =
  20 + if (LoadAdm(Migration))load_adm(file_name) is
  21 + {
  22 + file_not_found then print("File '"+file_name+"' not found.\n\n");failure,
  23 + read_error then print("Error reading file '"+file_name+"'.\n\n");failure,
  24 + timeout then print("Timeout when loading '"+file_name+"'.\n\n");failure,
  25 + file_damaged then print("File '"+file_name+"' is damaged.\n\n");failure,
  26 + bad_version(expected,found) then print("Secondary module '"+file_name+"' doesn't have the same\n"+
  27 + " version ("+found+") as primary module ("+expected+").\n\n");failure,
  28 + wrong_type(expected,found) then print("Secondary module '"+file_name+"' has different types\n\n");failure,
  29 + ok(db_migration) then println("db migration v"+db_migration.version+" module loaded ");success(db_migration)
  30 + }.
  31 +
  32 +public define List(Migration)
  33 + all_migrations
  34 + (
  35 + String app_dbm_path,
  36 + String app_name
  37 + )
  38 + =
  39 + with files = directory_list(app_dbm_path, app_name+"_dbm_to_v*.adm"),
  40 + all_list = map_select((String file_name) |-> load_dbm(app_dbm_path+file_name), files),
  41 + merge_sort(all_list, migration_less)
  42 +.