# `PhoenixKitManufacturing.Schemas.MachineTypeAssignment`
[🔗](https://github.com/BeamLabEU/phoenix_kit_manufacturing/blob/0.4.1/lib/phoenix_kit_manufacturing/schemas/machine_type_assignment.ex#L1)

Join table for the many-to-many between machines and machine types.

`machine_type_uuid` is a **soft reference** into `phoenix_kit_entities`
(`EntityData.uuid` for the `machine_type` entity), not an
`Ecto.Schema.belongs_to/3` association — `machine_type` data lives in a
separate package with no FK to point at (see
`PhoenixKitManufacturing.EntitiesRegistry`). `machine` stays a normal
association since `Machine` remains a schema of this module.

# `t`

```elixir
@type t() :: %PhoenixKitManufacturing.Schemas.MachineTypeAssignment{
  __meta__: term(),
  inserted_at: term(),
  machine: term(),
  machine_type_uuid: term(),
  machine_uuid: term(),
  updated_at: term(),
  uuid: term()
}
```

# `changeset`

```elixir
@spec changeset(t(), map()) :: Ecto.Changeset.t()
```

Builds an insert changeset for a machine ↔ type assignment.

Casts the two FK columns + timestamps and wires `assoc_constraint/2` on
the `machine` association so an FK violation comes back as a clean
`{:error, changeset}` instead of raising `Ecto.ConstraintError`.
`machine_type_uuid` is a soft reference (see moduledoc) — there is no
Postgres FK left to violate, so no `assoc_constraint/2` for it, but the
pair is still covered by `idx_machine_type_assignments_unique`
(core V144) — `unique_constraint/2` turns a duplicate-pair insert (e.g. a
caller passing the same type uuid twice) into the same clean
`{:error, changeset}` instead of an uncaught `Ecto.ConstraintError`.

---

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