View Source Authorizir.Migrations (Authorizir v2.0.0-alpha.5)

Migrations create and modify the database tables Authorizir needs to function.

usage

Usage

To use migrations in your application you'll need to generate an Ecto.Migration that wraps calls to Authorizir.Migrations:

mix ecto.gen.migration add_authorizir

Open the generated migration in your editor and call the up and down functions on Authorizir.Migrations:

defmodule MyApp.Repo.Migrations.AddAuthorizir do
  use Ecto.Migration

  def up, do: Authorizir.Migrations.up()

  def down, do: Authorizir.Migrations.down()
end

This will run all of Authorizir's versioned migrations for your database. Migrations between versions are idempotent. As new versions are released you may need to run additional migrations.

Now, run the migration to create the table:

mix ecto.migrate

Link to this section Summary

Functions

Run the down changes for all migrations between the current version and the initial version.

Run the up changes for all migrations between the initial version and the current version.

Link to this section Functions

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

Run the down changes for all migrations between the current version and the initial version.

example

Example

Run all migrations from current version down to the first:

Authorizir.Migrations.down()

Run migrations down to a specified version:

Authorizir.Migrations.down(version: 5)
@spec up(keyword()) :: :ok

Run the up changes for all migrations between the initial version and the current version.

example

Example

Run all migrations up to the current version:

Authorizir.Migrations.up()

Run migrations up to a specified version:

Authorizir.Migrations.up(version: 2)