# `Arcadic.Migration`
[🔗](https://github.com/baselabs/arcadic/blob/baselabs_arcadic-v4.0.1/lib/arcadic/migration.ex#L5)

Behaviour for an ArcadeDB migration — a versioned pair of forward/backward steps.
Migrations are tenant-blind schema changes; author raw DDL/DML via `Arcadic.command/4`
in `up/1` and `down/1`.

Only `:ok` finalizes a migration (`Arcadic.Migrator` marks it done); an
`{:error, reason}` return (or a raise) leaves the attempt's marker in place and the
next run follows the recovery contract in `Arcadic.Migrator`. Use the supplied
connection for synchronous database statements so Arcadic can verify the lease
before dispatch.

Implement `c:schema_only?/0` only if both directions consist of schema operations
that can safely replay after a partial attempt. Implement `c:preflight_down/1`
to verify that a reversal is safe. Preflight callbacks only read and validate.

    defmodule MyApp.Migrations.V1 do
      @behaviour Arcadic.Migration
      @impl true
      def version, do: 1
      @impl true
      def up(conn) do
        Arcadic.command!(conn, "CREATE VERTEX TYPE User IF NOT EXISTS", %{}, language: "sql")
        :ok
      end
      @impl true
      def down(conn) do
        Arcadic.command!(conn, "DROP TYPE User IF EXISTS", %{}, language: "sql")
        :ok
      end
    end

# `down`

```elixir
@callback down(Arcadic.Conn.t()) :: :ok | {:error, term()}
```

Reverse the migration. Only `:ok` finalizes; `{:error, reason}` leaves the attempt marker.

# `preflight_down`
*optional* 

```elixir
@callback preflight_down(Arcadic.Conn.t()) :: :ok | {:error, term()}
```

Check if reversal is safe. Read only and return value-free errors.

# `schema_only?`
*optional* 

```elixir
@callback schema_only?() :: boolean()
```

Whether either direction can safely replay after partially applied schema changes.

# `up`

```elixir
@callback up(Arcadic.Conn.t()) :: :ok | {:error, term()}
```

Apply the migration. Only `:ok` finalizes; `{:error, reason}` leaves the attempt marker.

# `version`

```elixir
@callback version() :: pos_integer()
```

A unique, ascending version (integer — typically a timestamp).

---

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