PhoenixKitManufacturing.Schemas.Machine (PhoenixKitManufacturing v0.3.2)

Copy Markdown View Source

Schema for manufacturing machines (the machines reference book).

A machine is a piece of production equipment: a CNC mill, a press, a laser cutter, etc. Machines are categorized by many-to-many machine type links via MachineTypeAssignment, so a single machine can carry several type tags. MachineTypeAssignment.machine_type_uuid is a soft reference (no belongs_to/FK) — see that schema's moduledoc — so this schema does not expose a machine_types association; resolving the linked types for a machine goes through PhoenixKitManufacturing.Machines/EntitiesRegistry instead.

The passport columns (model, manufacture_year, commissioned_on, warranty_until, to_last_on, to_interval_days, to_next_on, notes) and the soft location link (location_uuid, space_uuid) are first-class columns as of schema V2. location_uuid/space_uuid are intentionally not belongs_to associations — phoenix_kit_locations is a soft, optional cross-module reference read via PhoenixKitManufacturing.Machines.location_label/2, never joined.

to_next_on is auto-computed from to_last_on + to_interval_days whenever both are present and the caller didn't explicitly submit a to_next_on value of its own — see maybe_compute_next_maintenance/1.

The freeform metadata JSONB column holds the remaining passport/spec fields driven by each linked machine type's field_template (power rating, working area, …) that aren't modeled as columns here. data holds multilang translations.

Summary

Functions

Builds a changeset for a machine.

The list of valid status values.

Types

t()

@type t() :: %PhoenixKitManufacturing.Schemas.Machine{
  __meta__: term(),
  code: term(),
  commissioned_on: term(),
  data: term(),
  description: term(),
  inserted_at: term(),
  location_note: term(),
  location_uuid: term(),
  machine_type_assignments: term(),
  manufacture_year: term(),
  manufacturer: term(),
  metadata: term(),
  model: term(),
  name: term(),
  notes: term(),
  serial_number: term(),
  space_uuid: term(),
  status: term(),
  to_interval_days: term(),
  to_last_on: term(),
  to_next_on: term(),
  updated_at: term(),
  uuid: term(),
  warranty_until: term()
}

Functions

changeset(machine, attrs)

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

Builds a changeset for a machine.

statuses()

@spec statuses() :: [String.t()]

The list of valid status values.