Newer Older
55 lines | 1.683kb
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

            
Bogdan Timofte authored 3 days ago
36
`dhcp-router` este actualizat de endpoint-ul `POST /api/collect/dhcp-leases` când MikroTik împinge evenimente de lease de pe `192.168.2.1`.
37

            
Bogdan Timofte authored 4 days ago
38
## Definition
39

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

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