1
0
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:
Grzegorz Junka
2013-04-15 10:35:53 +00:00
parent d1aba9ae78
commit e1da643223
3 changed files with 11 additions and 8 deletions

8
.gitignore vendored
View File

@ -1,6 +1,8 @@
/ebin/
.eunit
deps
*.o
*.beam
*.plt
*.plt
/ebin/
/priv/migrate/
/include/tables.hrl

1
priv/migrate Symbolic link
View File

@ -0,0 +1 @@
../../../overlay/migresia/migrate

View File

@ -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).