Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] - Default Mix tasks #38

Open
cs-victor-nascimento opened this issue Sep 26, 2015 · 9 comments
Open

[FEATURE] - Default Mix tasks #38

cs-victor-nascimento opened this issue Sep 26, 2015 · 9 comments

Comments

@cs-victor-nascimento
Copy link
Contributor

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:

  • --no-schema: would not create the mnesia schema
  • --disc: would create passing the option disc:[node()]
  • --disc-only: same as above but with disc only on node
    ... and other mnesia options.

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
Copy link
Owner

meh commented Sep 26, 2015

Sounds good to me, go for it 👍

@cs-victor-nascimento
Copy link
Contributor Author

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

  • schema: true (will create schema before starting mnesia)
  • disc: true (this might be controversial, but it will follow README's task)
  • disc-only: false (only one of disc or disc-only will be allowed)

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
Copy link
Owner

meh commented Sep 27, 2015

How would that function be used?

@cs-victor-nascimento
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@cs-victor-nascimento
Copy link
Contributor Author

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

@matehat
Copy link
Contributor

matehat commented Jan 8, 2016

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
Copy link
Owner

meh commented Jan 8, 2016

@matehat released a new version.

@matehat
Copy link
Contributor

matehat commented Jan 8, 2016

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants