# `DrinkMeAlice.Ash.Schema`

SurrealQL DDL for resources using `DrinkMeAlice.Ash.DataLayer`,
shaped as `DrinkMeAlice.Migrations` migrations.

    migrations = [
      DrinkMeAlice.Ash.Schema.migration(1, "crew", [MyApp.Crew.Seat, MyApp.Crew.Mission])
    ]
    :ok = DrinkMeAlice.Admin.migrate(root_config, migrations)

Per resource: `DEFINE TABLE <t> SCHEMAFULL`, one `DEFINE FIELD` per
non-primary-key attribute (`option<T>` when `allow_nil?`), and a
`UNIQUE` index per identity. The primary key is the record id, not a
field. Migrations are append-only: once a version is applied its
statements are checksummed, so a changed resource needs a NEW
migration (e.g. `DEFINE FIELD … OVERWRITE`), never an edited one.

# `edge_statements`

```elixir
@spec edge_statements(binary(), binary(), binary(), [{binary(), binary()}]) :: [
  binary()
]
```

DDL for a graph edge table (`TYPE RELATION`), for use with
`DrinkMeAlice.Graph`. `fields` is `[{name, surreal_type}]`.

# `migration`

```elixir
@spec migration(pos_integer(), binary(), [module()]) ::
  DrinkMeAlice.Migrations.migration()
```

A migration map for `resources` (raises on an unsupported attribute type).

# `statements`

```elixir
@spec statements(module()) :: {:ok, [binary()]} | {:error, term()}
```

The DDL statements for one resource.

# `statements!`

Like `statements/1`, raising on error.

---

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