Enumex.Dynamic.Components.EctoSchema (Enumex v1.0.0)
View SourceGenerates ecto schemas for each enum definition.
Dependencies
Requires Ecto.Schema module from :ecto dependency.
Optional bindings
db_prefix- configures the schema prefix. Defaults tonil, which generates structs and queries without prefix. When set, the prefix will be used by every built struct and on queries whenever the schema is used in a from or a join. InPostgreSQL, the prefix is called "SCHEMA" (typically set via Postgres' search_path). InMySQLthe prefix points to databases.primary_key- configures the schema primary key. It expects a tuple {field_name, type, options} with the primary key field name, type (typically :id or :binary_id, but can be any type) and options. It also accepts false to disable the generation of a primary key field. Defaults tofalse.table_prefix- simply prefixes all table names for all enum definitions
Usage
defmodule MyApp.MyEnums do
use Enumex.Dynamic, components: [Enumex.Dynamic.Components.EctoSchema]
# or
use Enumex.Dynamic, components: [
{Enumex.Dynamic.Components.EctoSchema, [
db_prefix: "example",
primary_key: {:id, :string, autogenerate: false},
table_prefix: "my_enums_"
]}
]
# enum definitions goes here
end