elixir-lang/ecto — pull request #152 by Enders (2014-01-06 15:29:16+00:00)
Title: WIP: Storage management (mix task create/drop repo)

This is a WIP for issue #97, the purpose is to add two new mix tasks: ecto.create Repo and ecto.drop Repo.

Here is a summary of what's going on:

- [x] new mix task ecto.create + unit test
- [x] PG implementation of storage_up + integration test
- [ ] new mix task ecto.drop + unit test
- [ ] PG implementation of storage_down + integration test

I am sure there are many issues (hopefully, mostly Elixir syntax and not basic understood of what it was all about!!) with this proposed code, which is why I only implemented half of the feature -- no point going further unless this is OK!

Some remarks:

- I made Ecto.Repo.Backend.parse_url non-private (defp -> def) because I need it in the storage_up to retrieve username, password, hostname, etc. To me that's a sign parse_url should be moved to something more general to Ecto, maybe into a new Ecto.Repo.Utils or even Ecto.Utils? Any thoughts?

- I couldn't find a nice syntax for parsing the output from psql (available through the callback of Mix.Shell.cmd) to ensure that the failure reason is indeed that the storage is already up but it seems that the status code is enough... any suggestion?

- For passing the password to psql, I used the old trick of PGPASSWORD=xxxx, but I have read somewhere that it was deprecated... is there a newer approach? I think we can use password files, but that seems even messier...

Thanks for the review!