-module(migrant). -compile([no_auto_import, nowarn_unused_vars]). -export([migrate/2]). -spec migrate(sqlight:connection(), binary()) -> {ok, nil} | {error, migrant@types:error()}. migrate(Db, Migration_dir) -> migrant@database:create_migrations_table( Db, fun() -> migrant@filesystem:load_migration_files( Migration_dir, fun(Migrations) -> migrant@database:filter_applied_migrations( Db, Migrations, fun(Migrations@1) -> case migrant@database:apply_migrations( Db, Migrations@1 ) of {ok, _} -> {ok, nil}; {error, Err} -> gleam@io:debug(Err), erlang:error(#{gleam_error => panic, message => <<"Something went horribly wrong, see above for details."/utf8>>, module => <<"migrant"/utf8>>, function => <<"migrate"/utf8>>, line => 19}) end end ) end ) end ).