zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

ecto_sql.ex (1450B)


      1 defmodule Mix.EctoSQL do
      2   @moduledoc false
      3 
      4   @doc """
      5   Ensures the given repository's migrations paths exists on the file system.
      6   """
      7   @spec ensure_migrations_paths(Ecto.Repo.t, Keyword.t) :: [String.t]
      8   def ensure_migrations_paths(repo, opts) do
      9     paths = Keyword.get_values(opts, :migrations_path)
     10     paths = if paths == [], do: [Path.join(source_repo_priv(repo), "migrations")], else: paths
     11 
     12     if not Mix.Project.umbrella?() do
     13       for path <- paths, not File.dir?(path) do
     14         raise_missing_migrations(Path.relative_to_cwd(path), repo)
     15       end
     16     end
     17 
     18     paths
     19   end
     20 
     21   defp raise_missing_migrations(path, repo) do
     22     Mix.raise """
     23     Could not find migrations directory #{inspect path}
     24     for repo #{inspect repo}.
     25 
     26     This may be because you are in a new project and the
     27     migration directory has not been created yet. Creating an
     28     empty directory at the path above will fix this error.
     29 
     30     If you expected existing migrations to be found, please
     31     make sure your repository has been properly configured
     32     and the configured path exists.
     33     """
     34   end
     35 
     36   @doc """
     37   Returns the private repository path relative to the source.
     38   """
     39   def source_repo_priv(repo) do
     40     config = repo.config()
     41     priv = config[:priv] || "priv/#{repo |> Module.split() |> List.last() |> Macro.underscore()}"
     42     app = Keyword.fetch!(config, :otp_app)
     43     Path.join(Mix.Project.deps_paths()[app] || File.cwd!(), priv)
     44   end
     45 end