LocalAuthority / .doc / database / tables / work_order_actions.md
Newer Older
41 lines | 1.517kb
Bogdan Timofte authored 4 days ago
1
# Table: `work_order_actions`
2

            
3
Stores ordered actions attached to Work Orders.
4

            
5
## Columns
6

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

            
17
## Keys And Indexes
18

            
19
- Primary key: `(work_order_id, position)`
20

            
21
## Relationships
22

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

            
26
## Definition
27

            
28
```sql
29
CREATE TABLE IF NOT EXISTS work_order_actions (
30
    work_order_id TEXT NOT NULL,
31
    position INTEGER NOT NULL,
32
    type TEXT NOT NULL,
33
    host_fqdn TEXT,
34
    host_legacy_id TEXT NOT NULL DEFAULT '',
35
    name TEXT NOT NULL DEFAULT '',
36
    payload TEXT NOT NULL DEFAULT '',
37
    PRIMARY KEY (work_order_id, position),
38
    FOREIGN KEY (work_order_id) REFERENCES work_orders(id) ON UPDATE CASCADE ON DELETE CASCADE,
39
    FOREIGN KEY (host_fqdn) REFERENCES hosts(fqdn) ON UPDATE CASCADE ON DELETE SET NULL
40
);
41
```