Elixir mix task to generate Ecto models from already existing tables
Plsm generates Ecto models based on existing database tables in your database. Currently, Ecto only allows the ability to create migrations that creates new tables/schemas. If you have an existing project that you want to add Ecto support for you would have to hand code the models. This can be tedious for tables that have many columns.
You can add
{:plsm, "~> 2.3.2"}
to deps in your mix.exs and that will download the package for you
First, in order to run plsm, you need to generate a config file. You do this by running
mix plsm.config --config-file <name>
This will create a skeleton config file to the given config file. If you don't specify a config.exs file the config will then be appended to the "config/config.exs" file. If you are using another structure, such as Phoenix, then you need to pass in your dev.exs, since this is a dev only process. You will need to make changes to the generated Plsm configs in the config file in order to allow Plsm to function correctly.
Once you have your config file generated then you are ready to run plsm. You do this by running
mix plsm
You are able to change the location of the model file output in the configuration file
:mysql
or :postgres
. Do note that this is an atom and not a string
We currently support the following databases:
We may add support to other databases based on demand. Please reach out and if you want a specific database supported. Please feel free to contribute commits that add different database vendor support!
If you have any questions you can reach me via email at [email protected]