mirror of
https://github.com/UzixLS/migresia.git
synced 2025-07-18 23:01:21 +03:00
Use priv folder to store migrations and include folder to store a link to the .hrl file with table definitions - so that both are included when creating a new release
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,6 +1,8 @@
|
||||
/ebin/
|
||||
.eunit
|
||||
deps
|
||||
*.o
|
||||
*.beam
|
||||
*.plt
|
||||
*.plt
|
||||
|
||||
/ebin/
|
||||
/priv/migrate/
|
||||
/include/tables.hrl
|
||||
|
1
priv/migrate
Symbolic link
1
priv/migrate
Symbolic link
@ -0,0 +1 @@
|
||||
../../../overlay/migresia/migrate
|
@ -5,20 +5,20 @@
|
||||
-export([list_unapplied_ups/0]).
|
||||
|
||||
-define(APP, migresia).
|
||||
-define(DIR, <<"migrate">>).
|
||||
-define(TABLE, schema_migrations).
|
||||
|
||||
-spec list_unapplied_ups() -> [{module(), binary()}].
|
||||
list_unapplied_ups() ->
|
||||
application:load(?APP),
|
||||
get_migrations(application:get_env(?APP, dir)).
|
||||
get_migrations(filename:join(code:priv_dir(?APP), ?DIR)).
|
||||
|
||||
get_migrations(undefined) ->
|
||||
exit({undefined, migrate_dir});
|
||||
get_migrations({ok, Dir}) ->
|
||||
get_migrations({error, _} = Err) ->
|
||||
exit(Err);
|
||||
get_migrations(Dir) ->
|
||||
ToApply = check_dir(file:list_dir(Dir)),
|
||||
start_mnesia(),
|
||||
Applied = check_table(),
|
||||
%% io:format("ToApply:~n~p~nApplied:~n~p~n", [ToApply, Applied]),
|
||||
ToExecute = compile_unapplied(Dir, ToApply, Applied, []),
|
||||
Fun = fun({Module, Short, Binary}) -> load_migration(Module, Short, Binary) end,
|
||||
lists:map(Fun, ToExecute).
|
||||
|
Reference in New Issue
Block a user