meh / amnesia

Mnesia wrapper for Elixir.
692 stars 68 forks source link

[FEATURE] - Default Mix tasks #38

Open cs-victor-nascimento opened 8 years ago

cs-victor-nascimento commented 8 years ago

I think it would help a lot to have some default mix tasks like create|drop|migrate (same as those found in ecto for easier understanding). Your example of install/uninstall in the README is pretty much what everybody does when starting a project with amnesia INMHO.

We would only need to support something like:

mix amnesia.create --database MyDatabase (more options)

Options I can think of are:

To support migrate we could have some behaviour that would export a migrate function and we would receive the user module implementing that function. Again, close to Ecto's idiom.

I was starting out a PR but thought that it would be better to ask for opinions first. What do you think @meh?

meh commented 8 years ago

Sounds good to me, go for it :+1:

cs-victor-nascimento commented 8 years ago

Just so I get this right, I will use the following default values:

Drop task will accept an option --no-schema to destroy only the database. Defaults to false destroying also the schema.

Also, to make it easier to detect that the module is an amnesia database, I think we should add an __amnesia__/0 function. What do you think?

Migrate will probably go in a different PR...

meh commented 8 years ago

How would that function be used?

cs-victor-nascimento commented 8 years ago

Much like this line in Mix.Ecto.

I can also detect if the module has a defdatabase!/2 function... I guess it is not necessary to introduce a new function...

cs-victor-nascimento commented 8 years ago

Actually I will call metadata and check it returns a %Amnesia.Metadata{database: module}.

cs-victor-nascimento commented 8 years ago

[x] - Create mix task [x] - Drop mix task [ ] - Migrate mix task

matehat commented 8 years ago

Hello guys,

First of, #42

Second, if these new and shiny mix tasks are part of the official readme on the front page, they should also be part of the latest release people get when they install amnesia using hex. So maybe we should create a new release with the current master?

meh commented 8 years ago

@matehat released a new version.

matehat commented 8 years ago

:+1: