Newer Older
53 lines | 1.54kb
Bogdan Timofte authored 4 days ago
1
# Table: `data_workers`
2

            
3
Stores worker/source definitions for collected external data.
4

            
5
## Columns
6

            
7
| Column | Type | Null | Default | Notes |
8
|--------|------|------|---------|-------|
9
| `worker_id` | `TEXT` | no | none | Worker identifier. Primary key. |
10
| `worker_type` | `TEXT` | no | none | Worker type, for example `dhcp` or `mdns`. |
11
| `name` | `TEXT` | no | `''` | Human-readable name. |
12
| `status` | `TEXT` | no | `'active'` | Worker lifecycle state. |
13
| `source` | `TEXT` | no | `''` | Source endpoint/file. |
14
| `last_run_at` | `TEXT` | yes | `NULL` | Last successful collection timestamp. |
15
| `notes` | `TEXT` | no | `''` | Operator notes. |
16
| `created_at` | `TEXT` | no | none | ISO UTC creation timestamp. |
17
| `updated_at` | `TEXT` | no | none | ISO UTC update timestamp. |
18

            
19
## Keys And Indexes
20

            
21
- Primary key: `worker_id`
22
- Lookup index: `idx_data_workers_type_status` on `(worker_type, status)`
23

            
24
## Relationships
25

            
26
Referenced by:
27

            
28
- `dhcp_leases.worker_id`
29
- `mdns_observations.worker_id`
30

            
31
## Seed Rows
32

            
33
- `dhcp-router`, type `dhcp`
34
- `mdns-listener`, type `mdns`
35

            
36
## Definition
37

            
38
```sql
39
CREATE TABLE IF NOT EXISTS data_workers (
40
    worker_id TEXT PRIMARY KEY,
41
    worker_type TEXT NOT NULL,
42
    name TEXT NOT NULL DEFAULT '',
43
    status TEXT NOT NULL DEFAULT 'active',
44
    source TEXT NOT NULL DEFAULT '',
45
    last_run_at TEXT,
46
    notes TEXT NOT NULL DEFAULT '',
47
    created_at TEXT NOT NULL,
48
    updated_at TEXT NOT NULL
49
);
50

            
51
CREATE INDEX IF NOT EXISTS idx_data_workers_type_status
52
ON data_workers(worker_type, status);
53
```