Skip to content
This repository was archived by the owner on Mar 10, 2021. It is now read-only.

Commit 369e01e

Browse files
Merge pull request #32 from infinitered/bugfix/issue-30-migrations
Generate migrations with sequential timestamps
2 parents f109b34 + 3470eec commit 369e01e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/mix/tasks/thesis.install.ex

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ defmodule Mix.Tasks.Thesis.Install do
2929
@doc false
3030
def thesis_templates do
3131
migrations = ["create_thesis_tables", "add_meta_to_thesis_page_contents"]
32-
migration_files = Enum.filter_map(migrations, &migration_missing?/1, fn (filename) ->
33-
{"priv/templates/thesis.install/#{filename}.exs", "priv/repo/migrations/#{timestamp}_#{filename}.exs"}
34-
end)
32+
migration_files = migrations
33+
|> Enum.filter(&migration_missing?/1)
34+
|> Enum.with_index
35+
|> Enum.map(&migration_tuple/1)
3536

3637
template_files = [ {"priv/templates/thesis.install/thesis_auth.exs", "lib/thesis_auth.ex" } ]
3738

@@ -102,4 +103,9 @@ defmodule Mix.Tasks.Thesis.Install do
102103
|> File.ls!
103104
|> Enum.all?(fn (f) -> !String.contains?(f, filename) end)
104105
end
106+
107+
defp migration_tuple({filename, i}) do
108+
ts = String.to_integer(timestamp) + i
109+
{"priv/templates/thesis.install/#{filename}.exs", "priv/repo/migrations/#{ts}_#{filename}.exs"}
110+
end
105111
end

0 commit comments

Comments
 (0)