View Source Igniter.Libs.Ecto (igniter v0.5.0)

Codemods & utilities for working with Ecto

Summary

Functions

Generates a new migration file for the given repo.

Lists all the ecto repos in the project

Selects a repo module from the list of available repos.

Functions

gen_migration(igniter, repo, name, opts \\ [])

@spec gen_migration(
  Igniter.t(),
  repo :: module(),
  name :: String.t(),
  opts :: Keyword.t()
) ::
  Igniter.t()

Generates a new migration file for the given repo.

Options

  • :body - the body of the migration
  • :timestamp - the timestamp to use for the migration. Primarily useful for testing so you know what the filename will be.
  • :on_exists - what to do if the migration module already exists. Options are:
    • :increment - Calls this function again, but with an increasing number at the end, until it finds a free name. (default)
    • :skip - do nothing
    • :overwrite - overwrites the file
    • {:error, error} - adds an issue to the igniter that prevents writing and displays to the user
    • {:warning, warning} - adds a warning to the igniter that allows writing but displays to the user

list_repos(igniter)

@spec list_repos(Igniter.t()) :: {Igniter.t(), [module()]}

Lists all the ecto repos in the project

select_repo(igniter, opts \\ [])

@spec select_repo(Igniter.t(), Keyword.t()) :: {Igniter.t(), nil | module()}

Selects a repo module from the list of available repos.

Options

  • :label - The label to display to the user when selecting the repo