View Source EctoSessions.Migrations (Ecto Sessions v0.3.0)

Module to help you handle database migrations for EctoSessions. If you are just starting use this interface instead of calling migrations directly.

how-to

How-to

Create a migration with mix ecto.gen.migration AddEctoSessions, then paste the following:

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

  alias EctoSessions.Migrations

  def up, do: Migrations.up(
    table_name: "sessions",
    extra_fields: [{:user_id, :string}],
    create_extra_field_indexes: true
  )

  def down, do: Migrations.down()
end

Tweak the options according to your EctoSessions setup.

Link to this section Summary

Functions

Migrates EctoSessions up. Options

Link to this section Functions

Migrates EctoSessions up. Options:

  • prefix: The database prefix, as documented in Ecto.Repo, default to public
  • create_schema: If the schema should be created.
  • table_name: The session table name, defaults to sessions.
  • extra_fields: A list of tuples for the extra fields to create. Defaults to [user_id: :string].
  • create_extra_field_indexes: true to create unique indexes for the extra fields. Defaults to true.