Licet.Migration (Licet v0.1.0)

Copy Markdown View Source

Creates and drops Licet's tables.

mix licet.gen.migration generates an Ecto migration that calls this module:

defmodule Licet.Repo.Migrations.InstallLicet do
  use Ecto.Migration

  def up, do: Licet.Migration.up(prefix: "licet")

  def down, do: Licet.Migration.down(prefix: "licet")
end

The tables live in their own Postgres schema, named by :prefix. The statements use IF NOT EXISTS, so running up/1 twice is harmless. In tests, Licet.Testing.migrate!/2 runs the same statements without a migration.

Summary

Functions

Drops the prefix's Postgres schema and every table in it. Call it from an Ecto migration's down/0.

Returns the source of an Ecto migration module, as written by mix licet.gen.migration.

Returns the SQL statements that create the tables in a prefix.

Creates the tables. Call it from an Ecto migration's up/0.

Functions

down(opts \\ [])

@spec down(keyword()) :: :ok

Drops the prefix's Postgres schema and every table in it. Call it from an Ecto migration's down/0.

Options

  • :prefix - the Postgres schema to drop. Defaults to "licet".

migration_source(opts)

@spec migration_source(keyword()) :: String.t()

Returns the source of an Ecto migration module, as written by mix licet.gen.migration.

Options

  • :prefix - the Postgres schema for the tables. Defaults to "licet".
  • :module - the migration module name. Defaults to "Licet.Repo.Migrations.InstallLicet".

statements(prefix)

@spec statements(String.t() | keyword()) :: [String.t()]

Returns the SQL statements that create the tables in a prefix.

Takes a prefix string or a keyword list with :prefix, which defaults to "licet".

up(opts \\ [])

@spec up(keyword()) :: :ok

Creates the tables. Call it from an Ecto migration's up/0.

Options

  • :prefix - the Postgres schema for the tables. Defaults to "licet".