# `DurableObject.Migration`
[🔗](https://github.com/ChristianAlexander/durable_object/blob/v0.3.2/lib/durable_object/migration.ex#L1)

Versioned migrations for DurableObject tables.

## Usage

Generate a migration:

    mix ecto.gen.migration add_durable_objects

Then call the versioned migration functions:

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

      def up, do: DurableObject.Migration.up(version: 1)
      def down, do: DurableObject.Migration.down(version: 1)
    end

## Upgrading

When upgrading to a new version of DurableObject that requires schema changes,
generate a new migration and specify both the base version (already applied)
and the target version:

    mix ecto.gen.migration upgrade_durable_objects_v3

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

      def up, do: DurableObject.Migration.up(base: 2, version: 3)
      def down, do: DurableObject.Migration.down(base: 2, version: 3)
    end

This runs only version 3's changes, not versions 1-2 which are already applied.

# `current_version`
[🔗](https://github.com/ChristianAlexander/durable_object/blob/v0.3.2/lib/durable_object/migration.ex#L45)

Returns the current migration version.

# `down`
[🔗](https://github.com/ChristianAlexander/durable_object/blob/v0.3.2/lib/durable_object/migration.ex#L75)

Runs migrations down from the specified version.

## Options

  * `:version` - Version to roll back from (default: current version)
  * `:base` - Base version to roll back to (default: 0). Migrations will run from `version` down to `base + 1`.
  * `:prefix` - Table prefix for multi-tenancy (default: nil)

# `up`
[🔗](https://github.com/ChristianAlexander/durable_object/blob/v0.3.2/lib/durable_object/migration.ex#L56)

Runs migrations up to the specified version.

## Options

  * `:version` - Target version (default: current version)
  * `:base` - Base version already applied (default: 0). Migrations will run from `base + 1` to `version`.
  * `:prefix` - Table prefix for multi-tenancy (default: nil)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
