# Table: `work_order_actions`

Stores ordered actions attached to Work Orders.

## Columns

| Column | Type | Null | Default | Notes |
|--------|------|------|---------|-------|
| `work_order_id` | `TEXT` | no | none | Parent Work Order. References `work_orders(id)`. |
| `position` | `INTEGER` | no | none | Ordered action position. |
| `type` | `TEXT` | no | none | Action type, for example `remove_name`. |
| `host_fqdn` | `TEXT` | yes | `NULL` | Target host if resolved. References `hosts(fqdn)`. |
| `host_legacy_id` | `TEXT` | no | `''` | Compatibility target ID from old Work Order format. |
| `name` | `TEXT` | no | `''` | Target name for action. |
| `payload` | `TEXT` | no | `''` | Reserved structured payload field. |

## Keys And Indexes

- Primary key: `(work_order_id, position)`

## Relationships

- `work_order_id` references `work_orders(id)` with `ON UPDATE CASCADE ON DELETE CASCADE`
- `host_fqdn` references `hosts(fqdn)` with `ON UPDATE CASCADE ON DELETE SET NULL`

## Definition

```sql
CREATE TABLE IF NOT EXISTS work_order_actions (
    work_order_id TEXT NOT NULL,
    position INTEGER NOT NULL,
    type TEXT NOT NULL,
    host_fqdn TEXT,
    host_legacy_id TEXT NOT NULL DEFAULT '',
    name TEXT NOT NULL DEFAULT '',
    payload TEXT NOT NULL DEFAULT '',
    PRIMARY KEY (work_order_id, position),
    FOREIGN KEY (work_order_id) REFERENCES work_orders(id) ON UPDATE CASCADE ON DELETE CASCADE,
    FOREIGN KEY (host_fqdn) REFERENCES hosts(fqdn) ON UPDATE CASCADE ON DELETE SET NULL
);
```
