diff --git a/DATABASE.md b/DATABASE.md index 5322238..7b476e9 100644 --- a/DATABASE.md +++ b/DATABASE.md @@ -23,7 +23,7 @@ what the app actually creates. |---|---| | **File** | `DATABASE_PATH`, default `../data/homelab-manager.sqlite` (relative to `server/`; `/app/data/...` in Docker). The folder is created if missing. | | **Foreign keys** | Switched on for every connection (`PRAGMA foreign_keys = ON`), so the `ON DELETE` rules below are enforced. | -| **Migrations** | SQL files in [`server/drizzle/`](server/drizzle) (`0000` … `0063`), applied automatically when the server starts. Which ones have run is recorded in the table `__drizzle_migrations`. | +| **Migrations** | SQL files in [`server/drizzle/`](server/drizzle) (`0000` … `0064`), applied automatically when the server starts. Which ones have run is recorded in the table `__drizzle_migrations`. | | **Tables** | 78 application tables, plus drizzle's own `__drizzle_migrations`. | **Not in the database, but beside it in the data folder:** the backups of the database itself (`backups/homelab-manager-….sqlite`, taken daily and on request; see [BACKUP.md](BACKUP.md)), and, only while a restore is waiting or has just happened, `restore-pending.sqlite` / `restore-pending.json` and `restore-result.json`. @@ -140,7 +140,7 @@ Who changed what. Written by the app on every change (see | `id` | integer PK | | | `actor_user_id` | integer → `users.id`, **set null** on delete | Null for automatic actions, and for entries whose user was deleted. | | `actor_label` | text | The user's name/email as it was at the time (or `system`), so an entry still reads correctly after the account is gone. | -| `category` | text NOT NULL | Free text. In use: `server` (including the health check's own `went_offline`, `back_online`, `disk_full` and `disk_ok`, and `agent_updated` when a server's agent reports a higher version than before, written as `system` and shown on a server's Activity card), `integration` (including the health check's `went_failing` / `recovered` for a kind of service, with `target_type` `integration_type` and the service type as `target_id`, which the dashboard summary and the uptime ribbons read), `dns`, `settings` (including `agent_auto_update`), `ipam`, `secret`, `domain`, `tag`, `task`, `session`, `network`, `maintenance`, `consistency`, `user`, `privacy`, `diag_log`, `alert_ticket`, `dependency` (`create`, `delete` — what needs what), `endpoint` (`create`, `update`, `delete`), `restore_test` (`record`, `delete`), `push` (`subscribe`, `unsubscribe` — a browser added or removed, never its address or keys), `share_link` (a link made or removed, and `update_status_page` when what a status page shows is changed — never the secret), `runbook`, `note` (`save`, `delete`, `photo_add`, `photo_delete` — never the picture), `alert` (`ack`, `unack`, `snooze`, `unsnooze`, and `bulk_snooze` / `bulk_unsnooze` for several at once — with the alert's id; on the thing it is about, so they show on a server's Activity card), `incident` (`note`, `note_removed`), `duplicati` (`create_source`, `update_source`, `delete_source`, `update_backup`, `forget_backup`), `db_backup` (`create`, `upload`, `download`, `delete`, `restore_staged`, `restore_cancelled`, `settings`), `away` (`start`, `end` — with `automatic: true` when its time ran out), `update_run` (`start`, `finished`, `failed`, `cancelled` — shown on the server's Activity card), `inventory`, `metrics_token` and `webhook` (made, changed or removed — never a secret or an address). `user` also records `role_from_groups` when a sign-in changed someone's role. | +| `category` | text NOT NULL | Free text. In use: `server` (including the health check's own `went_offline`, `back_online`, `disk_full` and `disk_ok`, and `agent_updated` when a server's agent reports a higher version than before, written as `system` and shown on a server's Activity card), `integration` (including the health check's `went_failing` / `recovered` for a kind of service, with `target_type` `integration_type` and the service type as `target_id`, which the dashboard summary and the uptime ribbons read), `dns`, `settings` (including `agent_auto_update`), `ipam`, `secret`, `domain`, `tag`, `task`, `session`, `network`, `maintenance`, `consistency`, `user`, `privacy`, `diag_log`, `alert_ticket`, `dependency` (`create`, `delete` — what needs what), `endpoint` (`create`, `update`, `delete`), `restore_test` (`record`, `delete`), `push` (`subscribe`, `unsubscribe` — a browser added or removed, never its address or keys), `share_link` (a link made or removed, and `update_status_page` when what a status page shows is changed — never the secret), `runbook`, `note` (`save`, `delete`, `photo_add`, `photo_delete` — never the picture), `alert` (`ack`, `unack`, `snooze`, `unsnooze`, `close`, `reopen`, and `bulk_snooze` / `bulk_unsnooze` for several at once — with the alert's id; on the thing it is about, so they show on a server's Activity card), `incident` (`note`, `note_removed`), `duplicati` (`create_source`, `update_source`, `delete_source`, `update_backup`, `forget_backup`), `db_backup` (`create`, `upload`, `download`, `delete`, `restore_staged`, `restore_cancelled`, `settings`), `away` (`start`, `end` — with `automatic: true` when its time ran out), `update_run` (`start`, `finished`, `failed`, `cancelled` — shown on the server's Activity card), `inventory`, `metrics_token` and `webhook` (made, changed or removed — never a secret or an address). `user` also records `role_from_groups` when a sign-in changed someone's role. | | `action` | text NOT NULL | `create`, `update`, `delete`, `start`, `stop`, … — free text. | | `target_type`, `target_id` | text | What it happened to. `target_id` is text so it can hold any kind of ID; there's no foreign key. | | `detail` | text | JSON, free-form context (what changed, names, counts). Secrets are never put here. | @@ -1107,7 +1107,10 @@ An alert hidden until a time (see README, *Snooze*). Keyed like `alert_acks`, by | `alert_id` | text NOT NULL, unique | | | `condition_key` | text NOT NULL | The key behind it, which the notifications carry (so they can be held). | | `message` | text NOT NULL | What it said when it was snoozed. | -| `until` | text NOT NULL | ISO. When it has passed, an alert that is still there is announced again and the row is deleted. | +| `until` | text NOT NULL | ISO. When it has passed, an alert that is still there is announced again and the row is deleted. A **closed** alert has `9999-12-31T00:00:00.000Z`, which never comes. | +| `kind` | text NOT NULL, default `snooze` | `snooze`, or `closed` ("dealt with or accepted": hidden with no end, until it gets more serious than `severity` or has been gone for 30 minutes). | +| `severity` | text | For a closed alert: `critical`, `warning` or `info` as it was when it was closed. | +| `note` | text | For a closed alert: why. (It is also written on the incident.) | | `snoozed_by`, `snoozed_at` | text NOT NULL | | | `last_seen_at` | text NOT NULL | ISO; the last time the alert was there. A row whose alert has been gone for 30 minutes is deleted. | diff --git a/README.md b/README.md index 88b334e..c1490b4 100644 --- a/README.md +++ b/README.md @@ -966,6 +966,10 @@ maintenance — it is not counted in the menu badge, the dashboard or the digest promised about the thing. When the time comes an alert that is **still there is announced again, once** ("Snooze ended — an alert you snoozed is still there"); one that went away is simply gone. *Wake now* ends it early. A snooze, like an acknowledgement, is dropped once its alert has been gone for half an hour. The summaries that other checks send (stale backups, expiry, updates) are not held, only what is announced per alert. +**Close.** An alert also has **Close…** (operators), for one that has been **dealt with or is accepted** — fixed outside the app, or a warning you have decided to live with. It is hidden exactly like a snoozed one (not counted, its messages not sent) but **with no end**: it comes back only if it **gets worse** (a more serious +severity than it had when you closed it — "Closed alert got worse" is said once), or if the problem goes away for half an hour and returns, which makes it a new one. A number in its message changing (a disk at 91 %, then 92 %) does not open it. The reason you give is **written on its incident**, so the history says why, and +it shows beside the alert (*closed by Olga*; hover for the note). *Open again* brings it back at once. Closing is not maintenance: nothing is promised about the thing, use *Silence* for planned work. Closing, and opening again, are in the change log and the audit log. + **What changed before this?** Every incident page has a card with that name: what the app knows happened in the time before the alert began (30 minutes, 2, 6 or 24 hours), **ranked by how likely each is to be connected**. It looks through the audit log (settings, DNS, dependencies, a server being changed or going down), maintenance windows that began or ended, update runs and patch plans, other alerts raised first, and a step in the server's own figures (a disk that jumped from 50% to 73%). Each is scored from how *related* it is (the same thing; something it needs, such as the host it runs on or the diff --git a/ROLES.md b/ROLES.md index 9b17b6f..49cb7af 100644 --- a/ROLES.md +++ b/ROLES.md @@ -128,7 +128,7 @@ even further, to admin only: - **Away mode** (Settings → Notifications → When): administrators start, plan, change and end it, since it decides who is told what; everyone signed in sees the banner that says someone is away and how many notifications are held. - **Buttons on notifications** (Settings → Notifications → Who hears what): switching them on is administrator-only. A link in a notification needs **no role at all** — the signed token is the access, for the alerts in that message, for 24 hours, to acknowledge, silence for an hour or snooze, and nothing else. - **Alert rules** (Monitoring → Alert rules): everyone signed in sees the rules and where each is raised now; making, changing, trying, switching and removing one is administrator-only (a rule decides who is - woken up). **Snooze** an alert, and wake it, need operator, like acknowledging. The storage forecast beside Proxmox storages and Synology volumes is for everyone who can see those pages. + woken up). **Snooze** an alert, wake it, **close** it and open it again need operator, like acknowledging. The storage forecast beside Proxmox storages and Synology volumes is for everyone who can see those pages. - **What changed before this?** (on an incident's page, and `GET /api/v1/incidents/:id/before`): everyone signed in, like the incident record it is made from. - **Dependencies**: everyone can see what needs what; adding and removing one needs operator. So does adding or hiding a *suggested* one. - **To do and Notes** (Operations → To do, the *To do* and *Notes* cards on a server's page, a device's *Notes* drawer): everyone signed in reads them; adding, editing, ticking off and removing a job, and writing a note, and adding, captioning and removing a photo on one, need operator. diff --git a/docs/API.md b/docs/API.md index 50b3ad3..83ac177 100644 --- a/docs/API.md +++ b/docs/API.md @@ -159,6 +159,7 @@ curl -H "Authorization: Bearer hlm_p_xxxxxxxxxxxxxxxxxxxxxxxx" https://hm.exampl "url": "https://hm.example.lan/servers/1?view=history", "silenced": false, "snoozedUntil": null, + "closed": null, "flapping": false, "target": { "type": "server", "id": 1, "name": "wiki-host" }, "causedBy": null, @@ -180,6 +181,7 @@ curl -H "Authorization: Bearer hlm_p_xxxxxxxxxxxxxxxxxxxxxxxx" https://hm.exampl | `source` | Where it comes from: `Server`, `Proxmox`, `Synology`, `UniFi`, `Endpoint`, `Heartbeat` … | | `silenced` | Under a maintenance window, snoozed, or folded under a host that is down. Notifications for it are held back. | | `snoozedUntil` | When a snooze on it ends; `null` otherwise. | +| `closed` | `{ by, at, note }` when somebody has closed it (it is also `silenced`; a closed alert has no end — it opens again if it gets worse or has been gone for half an hour); `null` otherwise. | | `flapping` | It keeps being raised and cleared; its messages are being held back. | | `target` | What a maintenance window would silence it with (`server`, `integration`, `dns_provider` or `device`), or `null`. | | `causedBy` | The alert it is folded under, as `{ name, alertId? }`, or `null`. | diff --git a/docs/MONITORING.md b/docs/MONITORING.md index d9063bb..cc68c0b 100644 --- a/docs/MONITORING.md +++ b/docs/MONITORING.md @@ -37,7 +37,7 @@ This page explains what Homelab Manager watches, how often, how a problem become ``` agents ─────────┐ - integrations ───┤ ┌──► Alerts page ──► acknowledge · snooze · silence + integrations ───┤ ┌──► Alerts page ──► acknowledge · snooze · close · silence endpoint checks ┼─► checks ─► conditions ─┼──► notifications ─► Gotify · ntfy · email · webhook · push heartbeats ─────┤ (rules) "a problem" ├──► event webhooks (machines) your own rules ─┘ ├──► incidents (the record) and history @@ -428,6 +428,7 @@ Several things can quiet an alert. They are different, and it matters which you |---|---|---|---|---| | **Acknowledge** ("I'm on it") | No — it says someone has seen it, why, who has it | No: still listed, still counted in `/metrics`; leaves the *needs attention* count | Stops [escalation](#escalation) | When you choose (an hour … 30 days), or when the alert has been gone half an hour | | **Snooze** ("remind me tomorrow 09:00") | No | Yes, held back like maintenance | Raise/clear messages held; **one reminder** at the end if it is still there | At the time you set (up to 90 days), or earlier with *Wake now* | +| **Close** ("dealt with, or accepted") | Yes — with who and why, and the reason is written on the incident | Yes, held back like a snooze | Raise/clear messages held; **one message** only if it **gets worse** | Never by time: when it gets more serious than it was, when it has been gone half an hour, or with *Open again* | | **Maintenance window** | Yes — "I'm working on this" (5 minutes to a week) | Yes, marked *silenced* | Held for the server, integration, DNS provider or device | At its end; what is still there is then announced as **new** | | **Folded under a host** | — automatic | Nested under its cause | Not announced on its own | When the cause ends | | **Flapping** | — automatic | No | Raise and clear messages held; one "flapping" message, one "settled" message | After an hour of calm | @@ -525,6 +526,8 @@ For your own rules, raise the limit or lengthen the time. **I want to be reminded about something later, not silence it.** Snooze it. +**I have dealt with it, or I accept it, and I do not want to be reminded.** Close it (*Close…* on the Alerts page, with a reason). It stays closed until it gets worse than it was, or the problem goes away for half an hour and returns. + **I do not want to be woken for warnings.** Add a routing rule: kind or severity → the channels you want (a rule with no channels tells nobody; the Alerts page still shows it), and set quiet hours. **A job on a server has to run every night.** Make a heartbeat for it and call it from the end of the script. diff --git a/server/drizzle/0064_soft_wildside.sql b/server/drizzle/0064_soft_wildside.sql new file mode 100644 index 0000000..543334d --- /dev/null +++ b/server/drizzle/0064_soft_wildside.sql @@ -0,0 +1,3 @@ +ALTER TABLE `alert_snoozes` ADD `kind` text DEFAULT 'snooze' NOT NULL;--> statement-breakpoint +ALTER TABLE `alert_snoozes` ADD `severity` text;--> statement-breakpoint +ALTER TABLE `alert_snoozes` ADD `note` text; \ No newline at end of file diff --git a/server/drizzle/meta/0064_snapshot.json b/server/drizzle/meta/0064_snapshot.json new file mode 100644 index 0000000..d8cb79c --- /dev/null +++ b/server/drizzle/meta/0064_snapshot.json @@ -0,0 +1,7549 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "8ab777c3-496d-4a50-936d-d50dbb6df8f0", + "prevId": "84afb430-30a3-4299-b89b-c4ba922f4020", + "tables": { + "alert_acks": { + "name": "alert_acks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "alert_key": { + "name": "alert_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "assignee_user_id": { + "name": "assignee_user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "assignee_name": { + "name": "assignee_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "acked_by": { + "name": "acked_by", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "acked_at": { + "name": "acked_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "until": { + "name": "until", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "alert_acks_key_idx": { + "name": "alert_acks_key_idx", + "columns": [ + "alert_key" + ], + "isUnique": true + } + }, + "foreignKeys": { + "alert_acks_assignee_user_id_users_id_fk": { + "name": "alert_acks_assignee_user_id_users_id_fk", + "tableFrom": "alert_acks", + "tableTo": "users", + "columnsFrom": [ + "assignee_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "alert_incidents": { + "name": "alert_incidents", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "alert_key": { + "name": "alert_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "peak_severity": { + "name": "peak_severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "link": { + "name": "link", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_name": { + "name": "target_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "caused_by": { + "name": "caused_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "opened_at": { + "name": "opened_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "missing_since": { + "name": "missing_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "escalated_step": { + "name": "escalated_step", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "escalated_at": { + "name": "escalated_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "alert_incidents_key_idx": { + "name": "alert_incidents_key_idx", + "columns": [ + "alert_key" + ], + "isUnique": false + }, + "alert_incidents_opened_idx": { + "name": "alert_incidents_opened_idx", + "columns": [ + "opened_at" + ], + "isUnique": false + }, + "alert_incidents_target_idx": { + "name": "alert_incidents_target_idx", + "columns": [ + "target_type", + "target_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "alert_rules": { + "name": "alert_rules", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "metric": { + "name": "metric", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mount": { + "name": "mount", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "operator": { + "name": "operator", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'above'" + }, + "threshold": { + "name": "threshold", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "for_minutes": { + "name": "for_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'warning'" + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "alert_snoozes": { + "name": "alert_snoozes", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "alert_id": { + "name": "alert_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "condition_key": { + "name": "condition_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "until": { + "name": "until", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "snoozed_by": { + "name": "snoozed_by", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "snoozed_at": { + "name": "snoozed_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'snooze'" + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "alert_snoozes_alert_idx": { + "name": "alert_snoozes_alert_idx", + "columns": [ + "alert_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "alert_tickets": { + "name": "alert_tickets", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "alert_key": { + "name": "alert_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "seen_count": { + "name": "seen_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ticket_number": { + "name": "ticket_number", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "grouped": { + "name": "grouped", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ticketed_at": { + "name": "ticketed_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cleared_at": { + "name": "cleared_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "alert_tickets_key_idx": { + "name": "alert_tickets_key_idx", + "columns": [ + "alert_key" + ], + "isUnique": false + } + }, + "foreignKeys": { + "alert_tickets_integration_id_integrations_id_fk": { + "name": "alert_tickets_integration_id_integrations_id_fk", + "tableFrom": "alert_tickets", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "api_tokens": { + "name": "api_tokens", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_prefix": { + "name": "token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_used_at": { + "name": "last_used_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "api_tokens_token_hash_unique": { + "name": "api_tokens_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + } + }, + "foreignKeys": { + "api_tokens_user_id_users_id_fk": { + "name": "api_tokens_user_id_users_id_fk", + "tableFrom": "api_tokens", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "assets": { + "name": "assets", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'other'" + }, + "manufacturer": { + "name": "manufacturer", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "serial": { + "name": "serial", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "purchase_date": { + "name": "purchase_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "purchase_price": { + "name": "purchase_price", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "warranty_until": { + "name": "warranty_until", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "end_of_support": { + "name": "end_of_support", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "replacement_cost": { + "name": "replacement_cost", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "rack_unit": { + "name": "rack_unit", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "power_watts": { + "name": "power_watts", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "audit_log": { + "name": "audit_log", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor_label": { + "name": "actor_label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "audit_log_actor_user_id_users_id_fk": { + "name": "audit_log_actor_user_id_users_id_fk", + "tableFrom": "audit_log", + "tableTo": "users", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "authentik_state": { + "name": "authentik_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "latest_version": { + "name": "latest_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "outdated": { + "name": "outdated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "workers": { + "name": "workers", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "outposts": { + "name": "outposts", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "certificates": { + "name": "certificates", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "tokens": { + "name": "tokens", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "failed_logins_24h": { + "name": "failed_logins_24h", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "config_errors_24h": { + "name": "config_errors_24h", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_config_error": { + "name": "last_config_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "authentik_state_integration_id_integrations_id_fk": { + "name": "authentik_state_integration_id_integrations_id_fk", + "tableFrom": "authentik_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "consistency_ignores": { + "name": "consistency_ignores", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "consistency_ignores_key_unique": { + "name": "consistency_ignores_key_unique", + "columns": [ + "key" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dependencies": { + "name": "dependencies", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "from_type": { + "name": "from_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "from_id": { + "name": "from_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "to_type": { + "name": "to_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "to_id": { + "name": "to_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "dependencies_edge_idx": { + "name": "dependencies_edge_idx", + "columns": [ + "from_type", + "from_id", + "to_type", + "to_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "diag_log": { + "name": "diag_log", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "operation": { + "name": "operation", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "latency_ms": { + "name": "latency_ms", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dns_providers": { + "name": "dns_providers", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "provider_type": { + "name": "provider_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_id": { + "name": "credential_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "config": { + "name": "config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "dns_providers_credential_id_integration_credentials_id_fk": { + "name": "dns_providers_credential_id_integration_credentials_id_fk", + "tableFrom": "dns_providers", + "tableTo": "integration_credentials", + "columnsFrom": [ + "credential_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dns_records_cache": { + "name": "dns_records_cache", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "provider_id": { + "name": "provider_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "zone_id": { + "name": "zone_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "record_id": { + "name": "record_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ttl": { + "name": "ttl", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "priority": { + "name": "priority", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxied": { + "name": "proxied", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "dns_records_cache_provider_id_dns_providers_id_fk": { + "name": "dns_records_cache_provider_id_dns_providers_id_fk", + "tableFrom": "dns_records_cache", + "tableTo": "dns_providers", + "columnsFrom": [ + "provider_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dns_zones_cache": { + "name": "dns_zones_cache", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "provider_id": { + "name": "provider_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "zone_id": { + "name": "zone_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "zone_name": { + "name": "zone_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "synced_at": { + "name": "synced_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "dns_zones_cache_provider_zone_idx": { + "name": "dns_zones_cache_provider_zone_idx", + "columns": [ + "provider_id", + "zone_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "dns_zones_cache_provider_id_dns_providers_id_fk": { + "name": "dns_zones_cache_provider_id_dns_providers_id_fk", + "tableFrom": "dns_zones_cache", + "tableTo": "dns_providers", + "columnsFrom": [ + "provider_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "domains": { + "name": "domains", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'manual'" + }, + "expires_at": { + "name": "expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "registrar": { + "name": "registrar", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lookup_source": { + "name": "lookup_source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_checked_at": { + "name": "last_checked_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_checked_ok_at": { + "name": "last_checked_ok_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_check_error": { + "name": "last_check_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "domains_name_unique": { + "name": "domains_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "duplicati_backups": { + "name": "duplicati_backups", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "source_id": { + "name": "source_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_report_at": { + "name": "last_report_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_result": { + "name": "last_result", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_begin": { + "name": "last_begin", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_end": { + "name": "last_end", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "duration_seconds": { + "name": "duration_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "examined_files": { + "name": "examined_files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "added_files": { + "name": "added_files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "modified_files": { + "name": "modified_files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "deleted_files": { + "name": "deleted_files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "warnings": { + "name": "warnings", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "errors": { + "name": "errors", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_success_at": { + "name": "last_success_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "expected_hours": { + "name": "expected_hours", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 48 + }, + "alert": { + "name": "alert", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "duplicati_backups_name_idx": { + "name": "duplicati_backups_name_idx", + "columns": [ + "source_id", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "duplicati_backups_source_id_duplicati_sources_id_fk": { + "name": "duplicati_backups_source_id_duplicati_sources_id_fk", + "tableFrom": "duplicati_backups", + "tableTo": "duplicati_sources", + "columnsFrom": [ + "source_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "duplicati_runs": { + "name": "duplicati_runs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "backup_id": { + "name": "backup_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "duration_seconds": { + "name": "duration_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "files_changed": { + "name": "files_changed", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "warnings": { + "name": "warnings", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "errors": { + "name": "errors", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": { + "duplicati_runs_idx": { + "name": "duplicati_runs_idx", + "columns": [ + "backup_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "duplicati_runs_backup_id_duplicati_backups_id_fk": { + "name": "duplicati_runs_backup_id_duplicati_backups_id_fk", + "tableFrom": "duplicati_runs", + "tableTo": "duplicati_backups", + "columnsFrom": [ + "backup_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "duplicati_sources": { + "name": "duplicati_sources", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_prefix": { + "name": "token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_report_at": { + "name": "last_report_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "duplicati_sources_token_hash_unique": { + "name": "duplicati_sources_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "endpoint_checks": { + "name": "endpoint_checks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target": { + "name": "target", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "port": { + "name": "port", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expect_status": { + "name": "expect_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "keyword": { + "name": "keyword", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "insecure": { + "name": "insecure", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "value_path": { + "name": "value_path", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "value_op": { + "name": "value_op", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "value_expected": { + "name": "value_expected", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "value_unit": { + "name": "value_unit", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "header_name": { + "name": "header_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "header_value": { + "name": "header_value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_value": { + "name": "last_value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "interval_minutes": { + "name": "interval_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 5 + }, + "timeout_seconds": { + "name": "timeout_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 10 + }, + "failures_before_alert": { + "name": "failures_before_alert", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 2 + }, + "warn_days": { + "name": "warn_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 14 + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "last_checked_at": { + "name": "last_checked_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_ok": { + "name": "last_ok", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_message": { + "name": "last_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_response_ms": { + "name": "last_response_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cert_expires_at": { + "name": "cert_expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "last_change_at": { + "name": "last_change_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "endpoint_daily": { + "name": "endpoint_daily", + "columns": { + "check_id": { + "name": "check_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "day": { + "name": "day", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "total": { + "name": "total", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_sum": { + "name": "ms_sum", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_count": { + "name": "ms_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "endpoint_daily_check_id_endpoint_checks_id_fk": { + "name": "endpoint_daily_check_id_endpoint_checks_id_fk", + "tableFrom": "endpoint_daily", + "tableTo": "endpoint_checks", + "columnsFrom": [ + "check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "endpoint_daily_check_id_day_pk": { + "columns": [ + "check_id", + "day" + ], + "name": "endpoint_daily_check_id_day_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "endpoint_hourly": { + "name": "endpoint_hourly", + "columns": { + "check_id": { + "name": "check_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "hour": { + "name": "hour", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "total": { + "name": "total", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_sum": { + "name": "ms_sum", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_count": { + "name": "ms_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ms_max": { + "name": "ms_max", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "endpoint_hourly_check_id_endpoint_checks_id_fk": { + "name": "endpoint_hourly_check_id_endpoint_checks_id_fk", + "tableFrom": "endpoint_hourly", + "tableTo": "endpoint_checks", + "columnsFrom": [ + "check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "endpoint_hourly_check_id_hour_pk": { + "columns": [ + "check_id", + "hour" + ], + "name": "endpoint_hourly_check_id_hour_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "endpoint_results": { + "name": "endpoint_results", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "check_id": { + "name": "check_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ms": { + "name": "ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "endpoint_results_check_idx": { + "name": "endpoint_results_check_idx", + "columns": [ + "check_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "endpoint_results_check_id_endpoint_checks_id_fk": { + "name": "endpoint_results_check_id_endpoint_checks_id_fk", + "tableFrom": "endpoint_results", + "tableTo": "endpoint_checks", + "columnsFrom": [ + "check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "event_webhooks": { + "name": "event_webhooks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "events": { + "name": "events", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_attempt_at": { + "name": "last_attempt_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_result": { + "name": "last_result", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ha_entities": { + "name": "ha_entities", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "friendly_name": { + "name": "friendly_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "device_class": { + "name": "device_class", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_changed": { + "name": "last_changed", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "unavailable_since": { + "name": "unavailable_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "ha_entities_integration_id_integrations_id_fk": { + "name": "ha_entities_integration_id_integrations_id_fk", + "tableFrom": "ha_entities", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "ha_entities_integration_id_entity_id_pk": { + "columns": [ + "integration_id", + "entity_id" + ], + "name": "ha_entities_integration_id_entity_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ha_readings": { + "name": "ha_readings", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "ha_readings_lookup_idx": { + "name": "ha_readings_lookup_idx", + "columns": [ + "integration_id", + "entity_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "ha_readings_integration_id_integrations_id_fk": { + "name": "ha_readings_integration_id_integrations_id_fk", + "tableFrom": "ha_readings", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ha_watched": { + "name": "ha_watched", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "above": { + "name": "above", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "below": { + "name": "below", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "ha_watched_unique": { + "name": "ha_watched_unique", + "columns": [ + "integration_id", + "entity_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "ha_watched_integration_id_integrations_id_fk": { + "name": "ha_watched_integration_id_integrations_id_fk", + "tableFrom": "ha_watched", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "heartbeat_pings": { + "name": "heartbeat_pings", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "heartbeat_id": { + "name": "heartbeat_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "duration_ms": { + "name": "duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "heartbeat_pings_idx": { + "name": "heartbeat_pings_idx", + "columns": [ + "heartbeat_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "heartbeat_pings_heartbeat_id_heartbeats_id_fk": { + "name": "heartbeat_pings_heartbeat_id_heartbeats_id_fk", + "tableFrom": "heartbeat_pings", + "tableTo": "heartbeats", + "columnsFrom": [ + "heartbeat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "heartbeats": { + "name": "heartbeats", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "period_minutes": { + "name": "period_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "grace_minutes": { + "name": "grace_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 10 + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_ping_at": { + "name": "last_ping_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_status": { + "name": "last_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_message": { + "name": "last_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_duration_ms": { + "name": "last_duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_start_at": { + "name": "last_start_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ping_count": { + "name": "ping_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "heartbeats_token_unique": { + "name": "heartbeats_token_unique", + "columns": [ + "token" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "immich_state": { + "name": "immich_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "latest_version": { + "name": "latest_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "update_available": { + "name": "update_available", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "disk_size": { + "name": "disk_size", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disk_used": { + "name": "disk_used", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disk_percent": { + "name": "disk_percent", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "photos": { + "name": "photos", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "videos": { + "name": "videos", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "usage_bytes": { + "name": "usage_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "queues": { + "name": "queues", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "immich_state_integration_id_integrations_id_fk": { + "name": "immich_state_integration_id_integrations_id_fk", + "tableFrom": "immich_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "incident_notes": { + "name": "incident_notes", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "incident_id": { + "name": "incident_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "author": { + "name": "author", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "incident_notes_incident_idx": { + "name": "incident_notes_incident_idx", + "columns": [ + "incident_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "incident_notes_incident_id_alert_incidents_id_fk": { + "name": "incident_notes_incident_id_alert_incidents_id_fk", + "tableFrom": "incident_notes", + "tableTo": "alert_incidents", + "columnsFrom": [ + "incident_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "integration_credentials": { + "name": "integration_credentials", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "encrypted_secret": { + "name": "encrypted_secret", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "integrations": { + "name": "integrations", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_id": { + "name": "credential_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "config": { + "name": "config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "integrations_credential_id_integration_credentials_id_fk": { + "name": "integrations_credential_id_integration_credentials_id_fk", + "tableFrom": "integrations", + "tableTo": "integration_credentials", + "columnsFrom": [ + "credential_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ipam_entries": { + "name": "ipam_entries", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "vendor": { + "name": "vendor", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "ipam_entries_ip_address_unique": { + "name": "ipam_entries_ip_address_unique", + "columns": [ + "ip_address" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "jellyfin_readings": { + "name": "jellyfin_readings", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "streams": { + "name": "streams", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "transcodes": { + "name": "transcodes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "jellyfin_readings_idx": { + "name": "jellyfin_readings_idx", + "columns": [ + "integration_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "jellyfin_readings_integration_id_integrations_id_fk": { + "name": "jellyfin_readings_integration_id_integrations_id_fk", + "tableFrom": "jellyfin_readings", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "jellyfin_state": { + "name": "jellyfin_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "server_name": { + "name": "server_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os": { + "name": "os", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pending_restart": { + "name": "pending_restart", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "update_available": { + "name": "update_available", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "streams": { + "name": "streams", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "tasks": { + "name": "tasks", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "movies": { + "name": "movies", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "series": { + "name": "series", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "episodes": { + "name": "episodes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "songs": { + "name": "songs", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "failed_logins_24h": { + "name": "failed_logins_24h", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "jellyfin_state_integration_id_integrations_id_fk": { + "name": "jellyfin_state_integration_id_integrations_id_fk", + "tableFrom": "jellyfin_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "maintenance_aliases": { + "name": "maintenance_aliases", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "maintenance_aliases_unique_idx": { + "name": "maintenance_aliases_unique_idx", + "columns": [ + "address", + "target_type", + "target_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "maintenance_schedules": { + "name": "maintenance_schedules", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "targets": { + "name": "targets", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "days": { + "name": "days", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "duration_minutes": { + "name": "duration_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "maintenance_windows": { + "name": "maintenance_windows", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ends_at": { + "name": "ends_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "metrics_tokens": { + "name": "metrics_tokens", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_prefix": { + "name": "token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_used_at": { + "name": "last_used_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "metrics_tokens_token_hash_unique": { + "name": "metrics_tokens_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "n8n_state": { + "name": "n8n_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "workflows": { + "name": "workflows", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "executions_known": { + "name": "executions_known", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "n8n_state_integration_id_integrations_id_fk": { + "name": "n8n_state_integration_id_integrations_id_fk", + "tableFrom": "n8n_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "netbox_state": { + "name": "netbox_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "workers_running": { + "name": "workers_running", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "devices": { + "name": "devices", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "virtual_machines": { + "name": "virtual_machines", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "prefixes": { + "name": "prefixes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ip_addresses": { + "name": "ip_addresses", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ips": { + "name": "ips", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "netbox_state_integration_id_integrations_id_fk": { + "name": "netbox_state_integration_id_integrations_id_fk", + "tableFrom": "netbox_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "network_devices": { + "name": "network_devices", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "site_name": { + "name": "site_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'other'" + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mac": { + "name": "mac", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'other'" + }, + "uptime_seconds": { + "name": "uptime_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "firmware": { + "name": "firmware", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "firmware_updatable": { + "name": "firmware_updatable", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "uplink_external_id": { + "name": "uplink_external_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "offline_since": { + "name": "offline_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_online_at": { + "name": "last_online_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "network_devices_unique": { + "name": "network_devices_unique", + "columns": [ + "integration_id", + "external_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "network_devices_integration_id_integrations_id_fk": { + "name": "network_devices_integration_id_integrations_id_fk", + "tableFrom": "network_devices", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "network_segments": { + "name": "network_segments", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "site_name": { + "name": "site_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "vlan_id": { + "name": "vlan_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "subnet": { + "name": "subnet", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "security": { + "name": "security", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "network_name": { + "name": "network_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "network_segments_unique": { + "name": "network_segments_unique", + "columns": [ + "integration_id", + "kind", + "external_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "network_segments_integration_id_integrations_id_fk": { + "name": "network_segments_integration_id_integrations_id_fk", + "tableFrom": "network_segments", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "network_server_links": { + "name": "network_server_links", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "device_external_id": { + "name": "device_external_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_mac": { + "name": "client_mac", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "port": { + "name": "port", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "wired": { + "name": "wired", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "network_server_links_unique": { + "name": "network_server_links_unique", + "columns": [ + "integration_id", + "server_id", + "client_mac" + ], + "isUnique": true + } + }, + "foreignKeys": { + "network_server_links_integration_id_integrations_id_fk": { + "name": "network_server_links_integration_id_integrations_id_fk", + "tableFrom": "network_server_links", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "network_server_links_server_id_servers_id_fk": { + "name": "network_server_links_server_id_servers_id_fk", + "tableFrom": "network_server_links", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "nextcloud_state": { + "name": "nextcloud_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "maintenance": { + "name": "maintenance", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "needs_upgrade": { + "name": "needs_upgrade", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "detail": { + "name": "detail", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "free_bytes": { + "name": "free_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "users": { + "name": "users", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "files": { + "name": "files", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "active_24h": { + "name": "active_24h", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "app_updates": { + "name": "app_updates", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "nextcloud_state_integration_id_integrations_id_fk": { + "name": "nextcloud_state_integration_id_integrations_id_fk", + "tableFrom": "nextcloud_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "note_photos": { + "name": "note_photos", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "device_id": { + "name": "device_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "data": { + "name": "data", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "caption": { + "name": "caption", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "note_photos_server_idx": { + "name": "note_photos_server_idx", + "columns": [ + "server_id" + ], + "isUnique": false + }, + "note_photos_device_idx": { + "name": "note_photos_device_idx", + "columns": [ + "device_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "note_photos_server_id_servers_id_fk": { + "name": "note_photos_server_id_servers_id_fk", + "tableFrom": "note_photos", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "note_photos_device_id_network_devices_id_fk": { + "name": "note_photos_device_id_network_devices_id_fk", + "tableFrom": "note_photos", + "tableTo": "network_devices", + "columnsFrom": [ + "device_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notes": { + "name": "notes", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "notes_target_idx": { + "name": "notes_target_idx", + "columns": [ + "target_type", + "target_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notification_queue": { + "name": "notification_queue", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "audience": { + "name": "audience", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "paperless_state": { + "name": "paperless_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "latest_version": { + "name": "latest_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "update_available": { + "name": "update_available", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "storage_total": { + "name": "storage_total", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "storage_available": { + "name": "storage_available", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "components": { + "name": "components", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "documents": { + "name": "documents", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "inbox": { + "name": "inbox", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "failed": { + "name": "failed", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "paperless_state_integration_id_integrations_id_fk": { + "name": "paperless_state_integration_id_integrations_id_fk", + "tableFrom": "paperless_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "patch_plan_runs": { + "name": "patch_plan_runs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "plan_id": { + "name": "plan_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "plan_name": { + "name": "plan_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "started_by": { + "name": "started_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "items": { + "name": "items", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "started_at": { + "name": "started_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "finished_at": { + "name": "finished_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "patch_plan_runs_plan_idx": { + "name": "patch_plan_runs_plan_idx", + "columns": [ + "plan_id", + "started_at" + ], + "isUnique": false + }, + "patch_plan_runs_status_idx": { + "name": "patch_plan_runs_status_idx", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "patch_plan_runs_plan_id_patch_plans_id_fk": { + "name": "patch_plan_runs_plan_id_patch_plans_id_fk", + "tableFrom": "patch_plan_runs", + "tableTo": "patch_plans", + "columnsFrom": [ + "plan_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "patch_plans": { + "name": "patch_plans", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "days": { + "name": "days", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tags": { + "name": "tags", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "server_ids": { + "name": "server_ids", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "template_id": { + "name": "template_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "template_name": { + "name": "template_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "limit_from": { + "name": "limit_from", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'name'" + }, + "stop_on_failure": { + "name": "stop_on_failure", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "only_with_updates": { + "name": "only_with_updates", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "silence_dependents": { + "name": "silence_dependents", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "window_minutes": { + "name": "window_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 90 + }, + "last_run_date": { + "name": "last_run_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "port_forwards": { + "name": "port_forwards", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_port": { + "name": "external_port", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "protocol": { + "name": "protocol", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'tcp'" + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "destination": { + "name": "destination", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "internal_port": { + "name": "internal_port", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "port_forwards_server_id_servers_id_fk": { + "name": "port_forwards_server_id_servers_id_fk", + "tableFrom": "port_forwards", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "prometheus_state": { + "name": "prometheus_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "jobs": { + "name": "jobs", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "down": { + "name": "down", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "alerts": { + "name": "alerts", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "prometheus_state_integration_id_integrations_id_fk": { + "name": "prometheus_state_integration_id_integrations_id_fk", + "tableFrom": "prometheus_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "push_subscriptions": { + "name": "push_subscriptions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "p256dh": { + "name": "p256dh", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_success_at": { + "name": "last_success_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "min_severity": { + "name": "min_severity", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "categories": { + "name": "categories", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "push_subscriptions_endpoint_unique": { + "name": "push_subscriptions_endpoint_unique", + "columns": [ + "endpoint" + ], + "isUnique": true + } + }, + "foreignKeys": { + "push_subscriptions_user_id_users_id_fk": { + "name": "push_subscriptions_user_id_users_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "renewals": { + "name": "renewals", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "from_date": { + "name": "from_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "to_date": { + "name": "to_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "renewals_at_idx": { + "name": "renewals_at_idx", + "columns": [ + "at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "restore_tests": { + "name": "restore_tests", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "subject_key": { + "name": "subject_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tested_at": { + "name": "tested_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tested_by": { + "name": "tested_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "restore_tests_subject_idx": { + "name": "restore_tests_subject_idx", + "columns": [ + "subject_key", + "tested_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "runbooks": { + "name": "runbooks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "runbooks_target_idx": { + "name": "runbooks_target_idx", + "columns": [ + "target_type", + "target_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "scheduled_tasks": { + "name": "scheduled_tasks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "schedule_type": { + "name": "schedule_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'agent'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "command": { + "name": "command", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "schedule_expression": { + "name": "schedule_expression", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "next_run_at": { + "name": "next_run_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "raw_metadata": { + "name": "raw_metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_stale": { + "name": "is_stale", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "scheduled_tasks_server_id_servers_id_fk": { + "name": "scheduled_tasks_server_id_servers_id_fk", + "tableFrom": "scheduled_tasks", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "secrets": { + "name": "secrets", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'generic'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expiry_date": { + "name": "expiry_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "warn_days": { + "name": "warn_days", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 30 + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "check_host": { + "name": "check_host", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "check_port": { + "name": "check_port", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_checked_at": { + "name": "last_checked_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_check_error": { + "name": "last_check_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "server_links": { + "name": "server_links", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": { + "server_links_server_id_servers_id_fk": { + "name": "server_links_server_id_servers_id_fk", + "tableFrom": "server_links", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "server_metrics": { + "name": "server_metrics", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metric": { + "name": "metric", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "recorded_at": { + "name": "recorded_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "server_metrics_lookup_idx": { + "name": "server_metrics_lookup_idx", + "columns": [ + "server_id", + "metric", + "recorded_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "server_metrics_server_id_servers_id_fk": { + "name": "server_metrics_server_id_servers_id_fk", + "tableFrom": "server_metrics", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "server_metrics_rollup": { + "name": "server_metrics_rollup", + "columns": { + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metric": { + "name": "metric", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "grain": { + "name": "grain", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sum": { + "name": "sum", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "n": { + "name": "n", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "min": { + "name": "min", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "max": { + "name": "max", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "server_metrics_rollup_server_id_servers_id_fk": { + "name": "server_metrics_rollup_server_id_servers_id_fk", + "tableFrom": "server_metrics_rollup", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "server_metrics_rollup_server_id_metric_grain_at_pk": { + "columns": [ + "server_id", + "metric", + "grain", + "at" + ], + "name": "server_metrics_rollup_server_id_metric_grain_at_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "server_ports": { + "name": "server_ports", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "port": { + "name": "port", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "protocol": { + "name": "protocol", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'tcp'" + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "comment": { + "name": "comment", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "open": { + "name": "open", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "last_seen_open_at": { + "name": "last_seen_open_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "server_ports_unique": { + "name": "server_ports_unique", + "columns": [ + "server_id", + "port", + "protocol" + ], + "isUnique": true + } + }, + "foreignKeys": { + "server_ports_server_id_servers_id_fk": { + "name": "server_ports_server_id_servers_id_fk", + "tableFrom": "server_ports", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "servers": { + "name": "servers", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "hostname": { + "name": "hostname", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os_type": { + "name": "os_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'linux'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "api_token_hash": { + "name": "api_token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "api_token_prefix": { + "name": "api_token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ip_addresses": { + "name": "ip_addresses", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cpu_model": { + "name": "cpu_model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cpu_cores": { + "name": "cpu_cores", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cpu_load_percent": { + "name": "cpu_load_percent", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mem_total_bytes": { + "name": "mem_total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mem_used_bytes": { + "name": "mem_used_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disks": { + "name": "disks", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "listening_ports": { + "name": "listening_ports", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_port_scan": { + "name": "last_port_scan", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tags": { + "name": "tags", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxmox_integration_id": { + "name": "proxmox_integration_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxmox_node": { + "name": "proxmox_node", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxmox_guest_type": { + "name": "proxmox_guest_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "proxmox_vmid": { + "name": "proxmox_vmid", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hide_proxmox_link": { + "name": "hide_proxmox_link", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "parent_server_id": { + "name": "parent_server_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "no_parent": { + "name": "no_parent", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "pending_updates": { + "name": "pending_updates", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updates_pending_since": { + "name": "updates_pending_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "host_health": { + "name": "host_health", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_diagnostics": { + "name": "agent_diagnostics", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "port_baseline": { + "name": "port_baseline", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os_id": { + "name": "os_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os_name": { + "name": "os_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "os_version": { + "name": "os_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hw_manufacturer": { + "name": "hw_manufacturer", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hw_model": { + "name": "hw_model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hw_serial": { + "name": "hw_serial", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "thresholds": { + "name": "thresholds", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_version": { + "name": "agent_version", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "servers_proxmox_integration_id_integrations_id_fk": { + "name": "servers_proxmox_integration_id_integrations_id_fk", + "tableFrom": "servers", + "tableTo": "integrations", + "columnsFrom": [ + "proxmox_integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "service_levels": { + "name": "service_levels", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject_type": { + "name": "subject_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subject_id": { + "name": "subject_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target": { + "name": "target", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "alert": { + "name": "alert", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "settings": { + "name": "settings", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "share_links": { + "name": "share_links", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token_prefix": { + "name": "token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'summary'" + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'wall'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "expires_at": { + "name": "expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "share_links_token_hash_unique": { + "name": "share_links_token_hash_unique", + "columns": [ + "token_hash" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "status_items": { + "name": "status_items", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "link_id": { + "name": "link_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "monitor_id": { + "name": "monitor_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "status_items_link_idx": { + "name": "status_items_link_idx", + "columns": [ + "link_id", + "position" + ], + "isUnique": false + } + }, + "foreignKeys": { + "status_items_link_id_share_links_id_fk": { + "name": "status_items_link_id_share_links_id_fk", + "tableFrom": "status_items", + "tableTo": "share_links", + "columnsFrom": [ + "link_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "storage_samples": { + "name": "storage_samples", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "series_id": { + "name": "series_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "storage_samples_series_idx": { + "name": "storage_samples_series_idx", + "columns": [ + "series_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "storage_samples_series_id_storage_series_id_fk": { + "name": "storage_samples_series_id_storage_series_id_fk", + "tableFrom": "storage_samples", + "tableTo": "storage_series", + "columnsFrom": [ + "series_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "storage_series": { + "name": "storage_series", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "latest_percent": { + "name": "latest_percent", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "used_bytes": { + "name": "used_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "total_bytes": { + "name": "total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "storage_series_key_idx": { + "name": "storage_series_key_idx", + "columns": [ + "integration_id", + "key" + ], + "isUnique": true + } + }, + "foreignKeys": { + "storage_series_integration_id_integrations_id_fk": { + "name": "storage_series_integration_id_integrations_id_fk", + "tableFrom": "storage_series", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tag_definitions": { + "name": "tag_definitions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + } + }, + "indexes": { + "tag_definitions_name_unique": { + "name": "tag_definitions_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "todos": { + "name": "todos", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "detail": { + "name": "detail", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "due_date": { + "name": "due_date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "assignee_user_id": { + "name": "assignee_user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "assignee_name": { + "name": "assignee_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_id": { + "name": "target_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "done_at": { + "name": "done_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "done_by": { + "name": "done_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "todos_assignee_user_id_users_id_fk": { + "name": "todos_assignee_user_id_users_id_fk", + "tableFrom": "todos", + "tableTo": "users", + "columnsFrom": [ + "assignee_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "update_runs": { + "name": "update_runs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "server_id": { + "name": "server_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "template_id": { + "name": "template_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "template_name": { + "name": "template_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "host_limit": { + "name": "host_limit", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "task_status": { + "name": "task_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "window_id": { + "name": "window_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "window_created": { + "name": "window_created", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_by": { + "name": "started_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_ended_at": { + "name": "task_ended_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "host_reported_at": { + "name": "host_reported_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "finished_at": { + "name": "finished_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updates_before": { + "name": "updates_before", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updates_after": { + "name": "updates_after", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reboot_required": { + "name": "reboot_required", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "poll_errors": { + "name": "poll_errors", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": { + "update_runs_server_idx": { + "name": "update_runs_server_idx", + "columns": [ + "server_id", + "started_at" + ], + "isUnique": false + }, + "update_runs_status_idx": { + "name": "update_runs_status_idx", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "update_runs_server_id_servers_id_fk": { + "name": "update_runs_server_id_servers_id_fk", + "tableFrom": "update_runs", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ups_readings": { + "name": "ups_readings", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "charge": { + "name": "charge", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "runtime_seconds": { + "name": "runtime_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "load_percent": { + "name": "load_percent", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "input_voltage": { + "name": "input_voltage", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "on_battery": { + "name": "on_battery", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + } + }, + "indexes": { + "ups_readings_lookup_idx": { + "name": "ups_readings_lookup_idx", + "columns": [ + "integration_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "ups_readings_integration_id_integrations_id_fk": { + "name": "ups_readings_integration_id_integrations_id_fk", + "tableFrom": "ups_readings", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ups_state": { + "name": "ups_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "manufacturer": { + "name": "manufacturer", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status_text": { + "name": "status_text", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "on_battery": { + "name": "on_battery", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "low_battery": { + "name": "low_battery", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "replace_battery": { + "name": "replace_battery", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "overload": { + "name": "overload", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "charge": { + "name": "charge", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "runtime_seconds": { + "name": "runtime_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "load_percent": { + "name": "load_percent", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "input_voltage": { + "name": "input_voltage", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "output_voltage": { + "name": "output_voltage", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "on_battery_since": { + "name": "on_battery_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "ups_state_integration_id_integrations_id_fk": { + "name": "ups_state_integration_id_integrations_id_fk", + "tableFrom": "ups_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users": { + "name": "users", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "oidc_sub": { + "name": "oidc_sub", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'viewer'" + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(current_timestamp)" + }, + "last_login_at": { + "name": "last_login_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "favorites": { + "name": "favorites", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_looked_at": { + "name": "last_looked_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "groups": { + "name": "groups", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dashboard_layout": { + "name": "dashboard_layout", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "picture_url": { + "name": "picture_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "users_oidc_sub_unique": { + "name": "users_oidc_sub_unique", + "columns": [ + "oidc_sub" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "webhook_deliveries": { + "name": "webhook_deliveries", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "webhook_id": { + "name": "webhook_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "event": { + "name": "event", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "delivery_id": { + "name": "delivery_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "ok": { + "name": "ok", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "retry_of": { + "name": "retry_of", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "webhook_deliveries_webhook_idx": { + "name": "webhook_deliveries_webhook_idx", + "columns": [ + "webhook_id", + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "webhook_deliveries_webhook_id_event_webhooks_id_fk": { + "name": "webhook_deliveries_webhook_id_event_webhooks_id_fk", + "tableFrom": "webhook_deliveries", + "tableTo": "event_webhooks", + "columnsFrom": [ + "webhook_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/server/drizzle/meta/_journal.json b/server/drizzle/meta/_journal.json index 2a8147e..3fa915b 100644 --- a/server/drizzle/meta/_journal.json +++ b/server/drizzle/meta/_journal.json @@ -449,6 +449,13 @@ "when": 1792875717002, "tag": "0063_lucky_talkback", "breakpoints": true + }, + { + "idx": 64, + "version": "6", + "when": 1792957211279, + "tag": "0064_soft_wildside", + "breakpoints": true } ] } \ No newline at end of file diff --git a/server/src/db/schema.ts b/server/src/db/schema.ts index 8e24799..0f25912 100644 --- a/server/src/db/schema.ts +++ b/server/src/db/schema.ts @@ -1622,6 +1622,10 @@ export const alertSnoozes = sqliteTable( snoozedBy: text("snoozed_by").notNull(), snoozedAt: text("snoozed_at").notNull(), // ISO lastSeenAt: text("last_seen_at").notNull(), // ISO; the last time the alert was there + // A closed alert is a snooze with no end: hidden until it gets worse (a higher severity than `severity`, which is what it was when it was closed) or has gone for half an hour. + kind: text("kind").$type<"snooze" | "closed">().notNull().default("snooze"), + severity: text("severity"), // for a closed one: critical, warning or info as it was + note: text("note"), // for a closed one: why }, (t) => [uniqueIndex("alert_snoozes_alert_idx").on(t.alertId)], ); diff --git a/server/src/routes/alertActions.ts b/server/src/routes/alertActions.ts index 90394c7..4595155 100644 --- a/server/src/routes/alertActions.ts +++ b/server/src/routes/alertActions.ts @@ -64,7 +64,7 @@ alertActionsRouter.get("/:token", asyncHandler(async (req, res) => { continue; } const ack = await loadAck(alert.id, now); - const state = alert.snoozed ? `Snoozed until ${esc(new Date(alert.snoozed.until).toISOString().slice(0, 16).replace("T", " "))} UTC.` : ack?.active ? `Acknowledged by ${esc(ack.ackedBy)}.` : alert.silenced ? "Held back (under maintenance, or folded under something that is down)." : "Nobody has acknowledged it."; + const state = alert.closed ? `Closed by ${esc(alert.closed.by)}.` : alert.snoozed ?`Snoozed until ${esc(new Date(alert.snoozed.until).toISOString().slice(0, 16).replace("T", " "))} UTC.` : ack?.active ? `Acknowledged by ${esc(ack.ackedBy)}.` : alert.silenced ? "Held back (under maintenance, or folded under something that is down)." : "Nobody has acknowledged it."; const form = (action: ActionId, label: string, secondary = false) => `
`; cards += `
${esc(alert.severity)}
${esc(alert.message)}
${state}
${form("ack", "Acknowledge")}${alert.target ? form("silence", `Silence for ${SILENCE_MINUTES === 60 ? "an hour" : `${SILENCE_MINUTES} min`}`, true) : ""}${form("snooze", `Snooze until ${untilText}`, true)}
Open in Homelab Manager
`; diff --git a/server/src/routes/alerts.ts b/server/src/routes/alerts.ts index 614d8f7..2380f22 100644 --- a/server/src/routes/alerts.ts +++ b/server/src/routes/alerts.ts @@ -2,11 +2,11 @@ import { Router } from "express"; import { z } from "zod"; import { requireAuth, requireRole } from "../auth/middleware.js"; import { getAlerts, invalidateAlertsCache } from "../services/alerts.js"; -import { clearSnooze, setSnooze, SnoozeError } from "../services/alertSnoozes.js"; +import { clearSnooze, MAX_CLOSE_NOTE, setClosed, setSnooze, SnoozeError } from "../services/alertSnoozes.js"; import { keyOfAlertId } from "../services/flapGuard.js"; import { AckError, assignableUsers, attentionCounts, clearAck, loadAcks, MAX_HOURS, MAX_NOTE, setAck } from "../services/alertAcks.js"; import { recordAudit } from "../services/audit.js"; -import { openIncidentIds } from "../services/incidents.js"; +import { addNote, openIncidentIds } from "../services/incidents.js"; import { buildNoiseReport, NOISE_DAYS } from "../services/alertNoise.js"; import { ticketsForAlerts, type AlertTicketInfo } from "../services/alertTickets.js"; import { asyncHandler } from "../utils/asyncHandler.js"; @@ -133,3 +133,46 @@ alertsRouter.delete("/snooze", requireRole("operator"), asyncHandler(async (req, invalidateAlertsCache(); res.status(204).end(); })); + +const closeSchema = z.object({ + alertId: z.string().min(1).max(600), + /** Why — shown on the alert and written into its incident. */ + note: z.string().max(MAX_CLOSE_NOTE).nullable().optional(), +}); + +// "I have dealt with it, or I accept it": the alert is hidden with no end, until it gets worse or has gone for half an hour. The reason goes on the incident, so the history says why. +alertsRouter.put("/close", requireRole("operator"), asyncHandler(async (req, res) => { + const parsed = closeSchema.safeParse(req.body); + if (!parsed.success) return res.status(400).json({ error: "invalid_body", message: "Say which alert, and keep the note under " + MAX_CLOSE_NOTE + " characters." }); + const alert = (await getAlerts(false)).alerts.find((a) => a.id === parsed.data.alertId); + if (!alert) return res.status(404).json({ error: "not_found", message: "That alert isn't there any more." }); + const actor = req.currentUser!; + const who = actor.name ?? actor.email ?? actor.oidcSub; + try { + const closed = await setClosed({ alertId: alert.id, conditionKey: keyOfAlertId(alert.id, alert.category), message: alert.message, severity: alert.severity, note: parsed.data.note ?? null, actor: who }); + // The incident it is part of says it was closed, by whom and why. + const incidentId = (await openIncidentIds([alert.id])).get(alert.id); + if (incidentId) await addNote(incidentId, who, closed.note ? "Closed: " + closed.note : "Closed without a note."); + await recordAudit({ actor, category: "alert", action: "close", ...auditTargetOf(alert), detail: { alertId: alert.id, message: alert.message, note: closed.note } }); + invalidateAlertsCache(); + res.json({ closed: { by: closed.snoozedBy, at: closed.snoozedAt, note: closed.note } }); + } catch (err) { + if (err instanceof SnoozeError) return res.status(err.status).json({ error: err.code, message: err.message }); + throw err; + } +})); + +// Opens it again: it is shown, counted and announced like any other (and, if it is still there, is a new message to the people who get them). +alertsRouter.delete("/close", requireRole("operator"), asyncHandler(async (req, res) => { + const alertId = typeof req.query.alertId === "string" ? req.query.alertId : ""; + if (!alertId) return res.status(400).json({ error: "invalid_id" }); + const removed = await clearSnooze(alertId); + if (!removed) return res.status(404).json({ error: "not_found" }); + const actor = req.currentUser!; + const alert = (await getAlerts(false)).alerts.find((a) => a.id === alertId); + const incidentId = alert ? (await openIncidentIds([alertId])).get(alertId) : undefined; + if (incidentId) await addNote(incidentId, actor.name ?? actor.email ?? actor.oidcSub, "Opened again."); + await recordAudit({ actor, category: "alert", action: "reopen", ...(alert ? auditTargetOf(alert) : {}), detail: { alertId, message: removed.message } }); + invalidateAlertsCache(); + res.status(204).end(); +})); diff --git a/server/src/routes/bulk.ts b/server/src/routes/bulk.ts index 55d82a5..ce33d0d 100644 --- a/server/src/routes/bulk.ts +++ b/server/src/routes/bulk.ts @@ -103,7 +103,7 @@ const previousAck = z }) .nullable(); -const snoozeRecord = z.object({ conditionKey: z.string().max(700), message: z.string().max(500), until: z.string().max(40), snoozedBy: z.string().max(200), snoozedAt: z.string().max(40) }); +const snoozeRecord = z.object({ conditionKey: z.string().max(700), message: z.string().max(500), until: z.string().max(40), snoozedBy: z.string().max(200), snoozedAt: z.string().max(40), kind: z.enum(["snooze", "closed"]).optional(), severity: z.string().max(20).nullable().optional(), note: z.string().max(500).nullable().optional() }); const alertsBody = z.discriminatedUnion("action", [ /** When they should come back, as a date and time with its zone. */ diff --git a/server/src/services/alertSnoozes.ts b/server/src/services/alertSnoozes.ts index ed8059d..b93b5b2 100644 --- a/server/src/services/alertSnoozes.ts +++ b/server/src/services/alertSnoozes.ts @@ -30,9 +30,17 @@ export interface SnoozeInfo { until: string; snoozedBy: string; snoozedAt: string; + /** Closed rather than snoozed: it has no end, only the conditions in this file's header. */ + closed: boolean; + note: string | null; } -const shape = (r: typeof alertSnoozes.$inferSelect): SnoozeInfo => ({ until: r.until, snoozedBy: r.snoozedBy, snoozedAt: r.snoozedAt }); +const shape = (r: typeof alertSnoozes.$inferSelect): SnoozeInfo => ({ until: r.until, snoozedBy: r.snoozedBy, snoozedAt: r.snoozedAt, closed: r.kind === "closed", note: r.note }); + +/** A closed alert has no end; this is a date so far off that it never comes, which keeps every place that asks "is it still snoozed?" working as it is. */ +export const CLOSED_UNTIL = "9999-12-31T00:00:00.000Z"; +const SEVERITY_RANK: Record = { info: 0, warning: 1, critical: 2 }; +export const MAX_CLOSE_NOTE = 500; /** The snoozes still running, by alert id. */ export async function loadSnoozes(now: Date = new Date()): Promise> { @@ -55,9 +63,21 @@ export async function withoutSnoozed(items: T[], now export async function setSnooze(input: { alertId: string; conditionKey: string; message: string; until: Date; actor: string }, now: Date = new Date()): Promise { if (!(input.until.getTime() >= now.getTime() + MIN_AHEAD_MS)) throw new SnoozeError(400, "invalid_until", "Choose a time that has not come yet."); if (input.until.getTime() > now.getTime() + MAX_DAYS * 86_400_000) throw new SnoozeError(400, "invalid_until", `A snooze can be at most ${MAX_DAYS} days.`); - const values = { conditionKey: input.conditionKey, message: input.message.slice(0, 500), until: input.until.toISOString(), snoozedBy: input.actor, snoozedAt: now.toISOString(), lastSeenAt: now.toISOString() }; + const values = { conditionKey: input.conditionKey, message: input.message.slice(0, 500), until: input.until.toISOString(), snoozedBy: input.actor, snoozedAt: now.toISOString(), lastSeenAt: now.toISOString(), kind: "snooze" as const, severity: null, note: null }; await db.insert(alertSnoozes).values({ alertId: input.alertId, ...values }).onConflictDoUpdate({ target: alertSnoozes.alertId, set: values }); - return { until: values.until, snoozedBy: values.snoozedBy, snoozedAt: values.snoozedAt }; + return { until: values.until, snoozedBy: values.snoozedBy, snoozedAt: values.snoozedAt, closed: false, note: null }; +} + +/** + * Closes an alert: "I have dealt with it, or I accept it". It is hidden like a snoozed one, with no end — until it **gets worse** (a more serious severity than it had when it was + * closed) or has been **gone for half an hour** (the same problem coming back later is new). A number in its message changing (a disk at 91 %, then 92 %) is not a change. `note` says why. + */ +export async function setClosed(input: { alertId: string; conditionKey: string; message: string; severity: string; note: string | null; actor: string }, now: Date = new Date()): Promise { + const note = (input.note ?? "").trim(); + if (note.length > MAX_CLOSE_NOTE) throw new SnoozeError(400, "note_too_long", `Keep the note under ${MAX_CLOSE_NOTE} characters.`); + const values = { conditionKey: input.conditionKey, message: input.message.slice(0, 500), until: CLOSED_UNTIL, snoozedBy: input.actor, snoozedAt: now.toISOString(), lastSeenAt: now.toISOString(), kind: "closed" as const, severity: input.severity, note: note === "" ? null : note }; + await db.insert(alertSnoozes).values({ alertId: input.alertId, ...values }).onConflictDoUpdate({ target: alertSnoozes.alertId, set: values }); + return { until: values.until, snoozedBy: values.snoozedBy, snoozedAt: values.snoozedAt, closed: true, note: values.note }; } /** A snooze as it is stored, whole — what an undo puts back. */ @@ -67,12 +87,16 @@ export interface SnoozeRecord { until: string; snoozedBy: string; snoozedAt: string; + /** Left out of an older record: a snooze. */ + kind?: "snooze" | "closed"; + severity?: string | null; + note?: string | null; } -/** The snooze on an alert as it stands, expired or not; null when it has none. */ +/** The snooze (or the closing) on an alert as it stands, expired or not; null when it has none. */ export async function readSnooze(alertId: string): Promise { const [row] = await db.select().from(alertSnoozes).where(eq(alertSnoozes.alertId, alertId)).limit(1); - return row ? { conditionKey: row.conditionKey, message: row.message, until: row.until, snoozedBy: row.snoozedBy, snoozedAt: row.snoozedAt } : null; + return row ? { conditionKey: row.conditionKey, message: row.message, until: row.until, snoozedBy: row.snoozedBy, snoozedAt: row.snoozedAt, kind: row.kind, severity: row.severity, note: row.note } : null; } /** Puts a snooze back as it was (an undo). One whose time has already passed is not worth restoring: it would only announce the alert again at once, so it is dropped. */ @@ -81,7 +105,7 @@ export async function restoreSnooze(alertId: string, record: SnoozeRecord, now: await clearSnooze(alertId); return; } - const values = { ...record, lastSeenAt: now.toISOString() }; + const values = { ...record, kind: record.kind ?? ("snooze" as const), severity: record.severity ?? null, note: record.note ?? null, lastSeenAt: now.toISOString() }; await db.insert(alertSnoozes).values({ alertId, ...values }).onConflictDoUpdate({ target: alertSnoozes.alertId, set: values }); } @@ -96,11 +120,14 @@ export interface Reminder { key: string; message: string; severity?: string; + /** "ended": a snooze's time is up. "worse": a closed alert got more serious. */ + reason?: "ended" | "worse"; } /** * One look, with the alerts that are there now: snoozes that have run out are removed, and each whose alert is still there becomes a reminder; the others' alerts are - * marked as seen, and those that have been gone for half an hour are dropped. Returns the reminders to send. + * marked as seen, and those that have been gone for half an hour are dropped. A closed alert that is there with a higher severity than when it was closed is opened again, + * and announced as having got worse. Returns the reminders to send. */ export async function settleSnoozes(present: { id: string; message: string; severity: string; key: string }[], now: Date = new Date()): Promise { const rows = await db.select().from(alertSnoozes); @@ -112,8 +139,11 @@ export async function settleSnoozes(present: { id: string; message: string; seve const cutoff = new Date(now.getTime() - GONE_AFTER_MS).toISOString(); for (const r of rows) { const there = byId.get(r.alertId); - if (Date.parse(r.until) <= now.getTime()) { - if (there) reminders.push({ key: r.conditionKey, message: there.message, severity: there.severity }); + if (r.kind === "closed" && there && (SEVERITY_RANK[there.severity] ?? 0) > (SEVERITY_RANK[r.severity ?? ""] ?? 0)) { + reminders.push({ key: r.conditionKey, message: there.message, severity: there.severity, reason: "worse" }); + done.push(r.id); + } else if (Date.parse(r.until) <= now.getTime()) { + if (there) reminders.push({ key: r.conditionKey, message: there.message, severity: there.severity, reason: "ended" }); done.push(r.id); } else if (there) seen.push(r.id); else if (r.lastSeenAt < cutoff) done.push(r.id); diff --git a/server/src/services/alertTypes.ts b/server/src/services/alertTypes.ts index 6aa4b5f..24cdb6c 100644 --- a/server/src/services/alertTypes.ts +++ b/server/src/services/alertTypes.ts @@ -25,6 +25,8 @@ export interface Alert { affects?: string[]; /** Snoozed until then (services/alertSnoozes.ts): held back like one under maintenance, and announced again if it is still there. */ snoozed?: { until: string; by: string }; + /** Closed by somebody (services/alertSnoozes.ts): held back like a snoozed one, with no end — until it gets worse, or has gone for half an hour. */ + closed?: { by: string; at: string; note: string | null }; /** Raised and cleared over and over: its raised and cleared messages are being held back (services/flapGuard.ts). */ flapping?: boolean; /** What a maintenance window would have to be on to silence it, when there is such a thing — which is what "Silence" acts on. */ diff --git a/server/src/services/alerts.ts b/server/src/services/alerts.ts index 5f3e723..d434d72 100644 --- a/server/src/services/alerts.ts +++ b/server/src/services/alerts.ts @@ -684,12 +684,13 @@ export async function collectAlerts(): Promise { if (flapping.size > 0) for (const a of alerts) if (flapping.has(keyOfAlertId(a.id, a.category))) a.flapping = true; // Those somebody has snoozed are held back like those under maintenance, with when they come back. - const snoozes = await loadSnoozes().catch(() => new Map()); + const snoozes = await loadSnoozes().catch(() => new Map()); if (snoozes.size > 0) { for (const a of alerts) { const sn = snoozes.get(a.id); if (sn) { - a.snoozed = { until: sn.until, by: sn.snoozedBy }; + if (sn.closed) a.closed = { by: sn.snoozedBy, at: sn.snoozedAt, note: sn.note }; + else a.snoozed = { until: sn.until, by: sn.snoozedBy }; a.silenced = true; } } diff --git a/server/src/services/changeLog.ts b/server/src/services/changeLog.ts index aa274f0..3165356 100644 --- a/server/src/services/changeLog.ts +++ b/server/src/services/changeLog.ts @@ -223,6 +223,10 @@ export function describeChange(category: string, action: string, detail: Record< return { title: `Alert rule removed${name ? `: ${name}` : ""}`, tone: "neutral", detail: null }; case "alert/snooze": return { title: `Alert snoozed${typeof detail.message === "string" ? `: ${detail.message}` : ""}`, tone: "neutral", detail: str(detail.until) ? `until ${str(detail.until)}` : null }; + case "alert/close": + return { title: `Alert closed${typeof detail.message === "string" ? `: ${detail.message}` : ""}`, tone: "neutral", detail: str(detail.note) }; + case "alert/reopen": + return { title: `Closed alert opened again${typeof detail.message === "string" ? `: ${detail.message}` : ""}`, tone: "neutral", detail: null }; case "alert/unsnooze": return { title: `Snooze ended early${typeof detail.message === "string" ? `: ${detail.message}` : ""}`, tone: "neutral", detail: null }; case "alert/flapping_started": diff --git a/server/src/services/notify.ts b/server/src/services/notify.ts index 5093b9f..fa7163e 100644 --- a/server/src/services/notify.ts +++ b/server/src/services/notify.ts @@ -517,6 +517,15 @@ export async function notifySnoozeEnded(items: { message: string; key?: string; }), (i) => i.key); } +/** Alerts that somebody closed and that have since got more serious: opened again, and said once. */ +export async function notifyClosedWorse(items: { message: string; key?: string; severity?: string }[]): Promise { + if (items.length === 0) return; + await notifyGrouped(items, issueMeta, (group) => ({ + title: "Homelab Manager — Closed alert got worse", + message: `${group.length === 1 ? "An alert you closed is" : `${group.length} alerts you closed are`} more serious now, so ${group.length === 1 ? "it is" : "they are"} open again:\n\n${group.map((i) => `⚠ ${i.message}`).join("\n")}`, + }), (i) => i.key); +} + /** An alert that has just been called flapping: said once, with how often it has come, instead of each time. */ export async function notifyFlapping(items: { message: string; key?: string; severity?: string; count: number }[]): Promise { if (items.length === 0) return; diff --git a/server/src/services/publicApi.ts b/server/src/services/publicApi.ts index 94c8378..abe80cd 100644 --- a/server/src/services/publicApi.ts +++ b/server/src/services/publicApi.ts @@ -100,6 +100,8 @@ export async function alertsV1() { flapping: !!a.flapping, // Snoozed alerts are also `silenced`; this says until when they are. snoozedUntil: a.snoozed?.until ?? null, + // Closed ones are `silenced` too; this says by whom and why. They have no end. + closed: a.closed ? { by: a.closed.by, at: a.closed.at, note: a.closed.note } : null, target: a.target, causedBy: a.causedBy ?? null, affects: a.affects ?? [], diff --git a/server/src/services/snoozeMonitor.ts b/server/src/services/snoozeMonitor.ts index db639f8..785f85f 100644 --- a/server/src/services/snoozeMonitor.ts +++ b/server/src/services/snoozeMonitor.ts @@ -4,7 +4,7 @@ import { getAlerts, invalidateAlertsCache } from "./alerts.js"; import { keyOfAlertId } from "./flapGuard.js"; import { settleSnoozes } from "./alertSnoozes.js"; -import { notifySnoozeEnded } from "./notify.js"; +import { notifyClosedWorse, notifySnoozeEnded } from "./notify.js"; /** One look: returns how many reminders were sent. */ export async function remindAboutSnoozed(now: Date = new Date()): Promise { @@ -13,7 +13,8 @@ export async function remindAboutSnoozed(now: Date = new Date()): Promise 0) { // The page should show them again at once, not when its stored result expires. invalidateAlertsCache(); - await notifySnoozeEnded(reminders); + await notifySnoozeEnded(reminders.filter((r) => r.reason !== "worse")); + await notifyClosedWorse(reminders.filter((r) => r.reason === "worse")); } return reminders.length; } diff --git a/server/test/alertClose.test.ts b/server/test/alertClose.test.ts new file mode 100644 index 0000000..ed3fdde --- /dev/null +++ b/server/test/alertClose.test.ts @@ -0,0 +1,206 @@ +/** + * Closing an alert: hidden with no end, until it gets worse or has been gone for half an hour; why it was closed goes on its incident; it can be opened again; and how it sits + * beside snoozing. + * + * Run with: npm test --workspace server + */ +import { test, describe, before, after } from "node:test"; +import assert from "node:assert/strict"; +import { mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import type { AddressInfo } from "node:net"; +import type { Server } from "node:http"; + +const dir = mkdtempSync(join(tmpdir(), "hm-close-")); +process.env.DATABASE_PATH = join(dir, "test.sqlite"); +process.env.SESSION_DIR = join(dir, "sessions"); +process.env.CREDENTIALS_ENCRYPTION_KEY = "ab".repeat(32); +process.env.HEALTH_STARTUP_GRACE_MS = "0"; + +const express = (await import("express")).default; +const { db } = await import("../src/db/client.js"); +const { users, heartbeats, alertSnoozes, auditLog } = await import("../src/db/schema.js"); +const { runMigrations } = await import("../src/db/migrate.js"); +const { alertsRouter } = await import("../src/routes/alerts.js"); +const { alertsBulkRouter } = await import("../src/routes/bulk.js"); +const { getAlerts, invalidateAlertsCache } = await import("../src/services/alerts.js"); +const { setClosed, setSnooze, settleSnoozes, withoutSnoozed, loadSnoozes, GONE_AFTER_MS, CLOSED_UNTIL } = await import("../src/services/alertSnoozes.js"); +const { getIncident, openIncidentIds } = await import("../src/services/incidents.js"); +const { getChangeLog } = await import("../src/services/changeLog.js"); +const { eq } = await import("drizzle-orm"); + +await runMigrations(); + +let app: Server; +let base = ""; +let who = "operator"; +const call = async (method: string, path: string, body?: unknown) => { + const res = await fetch(`${base}${path}`, { method, headers: { "content-type": "application/json" }, body: body === undefined ? undefined : JSON.stringify(body) }); + return { status: res.status, body: (await res.json().catch(() => null)) as any }; +}; +const idOfHeartbeat = async (name: string) => { + invalidateAlertsCache(); + const report = await getAlerts(true); + const a = report.alerts.find((x) => x.message.startsWith(name)); + assert.ok(a, `an alert about ${name}`); + return a!; +}; + +before(async () => { + await db.insert(users).values([ + { oidcSub: "operator", name: "Olga", role: "operator" }, + { oidcSub: "viewer", name: "Vic", role: "viewer" }, + ]); + const old = "2026-01-01 00:00:00"; + for (const name of ["jobA", "jobB"]) await db.insert(heartbeats).values({ name, token: `hb_${name}`.padEnd(24, "x"), periodMinutes: 60, graceMinutes: 5, serverId: null, createdAt: old }); + const a = express(); + a.use(express.json()); + a.use((req, _res, next) => { + (req as unknown as { session: unknown }).session = { user: { sub: who } }; + next(); + }); + a.use("/api/alerts/bulk", alertsBulkRouter); + a.use("/api/alerts", alertsRouter); + app = await new Promise((resolve) => { + const s = a.listen(0, "127.0.0.1", () => resolve(s)); + }); + base = `http://127.0.0.1:${(app.address() as AddressInfo).port}/api/alerts`; +}); +after(() => { + app.close(); + try { + rmSync(dir, { recursive: true, force: true }); + } catch { + // Windows keeps the database file locked until the process exits. + } +}); + +describe("closing through the route", () => { + test("a closed alert is held back like a snoozed one, with who closed it and why; it is not counted as needing attention", async () => { + const a = await idOfHeartbeat("jobA"); + assert.equal(a.silenced, false); + const attention = (c: { critical: number; warning: number; info: number }) => c.critical + c.warning + c.info; + const before = (await getAlerts(false)).counts; + const r = await call("PUT", "/close", { alertId: a.id, note: " Replaced the job; the old one is retired. " }); + assert.equal(r.status, 200); + assert.deepEqual([r.body.closed.by, r.body.closed.note], ["Olga", "Replaced the job; the old one is retired."]); + invalidateAlertsCache(); + const report = await getAlerts(true); + const after = report.alerts.find((x) => x.id === a.id)!; + assert.deepEqual([after.silenced, after.closed?.by, after.closed?.note, after.snoozed], [true, "Olga", "Replaced the job; the old one is retired.", undefined]); + assert.equal(attention(report.counts), attention(before) - 1, "no longer among those that need a look"); + assert.equal(report.counts.silenced, before.silenced + 1, "counted as held back"); + }); + + test("the reason is written on the incident, and opening it again says so there too", async () => { + const a = await idOfHeartbeat("jobA"); + const incidentId = (await openIncidentIds([a.id])).get(a.id)!; + assert.ok(incidentId, "an incident is open for it"); + let notes = (await getIncident(incidentId))!.notes.map((n) => [n.author, n.body]); + assert.deepEqual(notes, [["Olga", "Closed: Replaced the job; the old one is retired."]]); + assert.equal((await call("DELETE", `/close?alertId=${encodeURIComponent(a.id)}`)).status, 204); + notes = (await getIncident(incidentId))!.notes.map((n) => [n.author, n.body]); + assert.deepEqual(notes.at(-1), ["Olga", "Opened again."]); + invalidateAlertsCache(); + const again = (await getAlerts(true)).alerts.find((x) => x.id === a.id)!; + assert.deepEqual([again.silenced, again.closed], [false, undefined], "shown and counted again"); + }); + + test("it is in the audit log and the change log as sentences; closing without a note says so on the incident", async () => { + const a = await idOfHeartbeat("jobB"); + assert.equal((await call("PUT", "/close", { alertId: a.id })).status, 200); + const incidentId = (await openIncidentIds([a.id])).get(a.id)!; + assert.deepEqual((await getIncident(incidentId))!.notes.map((n) => n.body), ["Closed without a note."]); + await call("DELETE", `/close?alertId=${encodeURIComponent(a.id)}`); + const actions = (await db.select().from(auditLog)).map((e) => `${e.category}/${e.action}`); + assert.ok(actions.includes("alert/close") && actions.includes("alert/reopen")); + const titles = (await getChangeLog({ days: 1, limit: 300 })).entries.map((e) => e.title); + assert.ok(titles.some((t) => /^Alert closed: jobA/.test(t)), "closed"); + assert.ok(titles.some((t) => /^Closed alert opened again: jobA/.test(t)), "opened again"); + }); + + test("an alert that is not there is not found, a note that is too long is refused, a viewer cannot close or open", async () => { + assert.equal((await call("PUT", "/close", { alertId: "monitoring:nothing:1" })).status, 404); + const a = await idOfHeartbeat("jobA"); + const long = await call("PUT", "/close", { alertId: a.id, note: "x".repeat(501) }); + assert.equal(long.status, 400); + who = "viewer"; + assert.equal((await call("PUT", "/close", { alertId: a.id })).status, 403); + assert.equal((await call("DELETE", `/close?alertId=${encodeURIComponent(a.id)}`)).status, 403); + who = "operator"; + assert.equal((await call("DELETE", `/close?alertId=${encodeURIComponent(a.id)}`)).status, 404, "nothing to open"); + }); + + test("closing an alert that is snoozed makes it closed, and snoozing a closed one makes it a snooze again", async () => { + const a = await idOfHeartbeat("jobA"); + const until = new Date(Date.now() + 3_600_000).toISOString(); + assert.equal((await call("PUT", "/snooze", { alertId: a.id, until })).status, 200); + assert.equal((await call("PUT", "/close", { alertId: a.id })).status, 200); + let [row] = await db.select().from(alertSnoozes).where(eq(alertSnoozes.alertId, a.id)); + assert.deepEqual([row.kind, row.until], ["closed", CLOSED_UNTIL]); + assert.equal((await call("PUT", "/snooze", { alertId: a.id, until })).status, 200); + [row] = await db.select().from(alertSnoozes).where(eq(alertSnoozes.alertId, a.id)); + assert.deepEqual([row.kind, row.severity, row.note], ["snooze", null, null]); + await call("DELETE", `/snooze?alertId=${encodeURIComponent(a.id)}`); + }); + + test("a bulk snooze over a closed alert can be undone back to closed, with its note", async () => { + const a = await idOfHeartbeat("jobA"); + await call("PUT", "/close", { alertId: a.id, note: "accepted" }); + const r = await call("POST", "/bulk", { action: "snooze", alertIds: [a.id], until: new Date(Date.now() + 3_600_000).toISOString() }); + assert.equal(r.body.changed, 1); + assert.equal((await db.select().from(alertSnoozes).where(eq(alertSnoozes.alertId, a.id)))[0].kind, "snooze"); + await call("POST", "/bulk", r.body.undo); + const [row] = await db.select().from(alertSnoozes).where(eq(alertSnoozes.alertId, a.id)); + assert.deepEqual([row.kind, row.note, row.until], ["closed", "accepted", CLOSED_UNTIL]); + await call("DELETE", `/close?alertId=${encodeURIComponent(a.id)}`); + }); +}); + +describe("until it gets worse", () => { + const present = (id: string, severity: string, message = "disk is 91% full") => [{ id, message, severity, key: `k:${id}` }]; + const NOW = new Date(); + + test("the same alert stays closed however its message changes, and a milder severity does not open it", async () => { + await db.delete(alertSnoozes); + await setClosed({ alertId: "x1", conditionKey: "k:x1", message: "disk is 91% full", severity: "warning", note: null, actor: "Olga" }, NOW); + assert.deepEqual(await settleSnoozes(present("x1", "warning", "disk is 94% full"), NOW), []); + assert.deepEqual(await settleSnoozes(present("x1", "info", "disk is 80% full"), NOW), []); + assert.equal((await db.select().from(alertSnoozes)).length, 1, "still closed"); + assert.equal((await loadSnoozes(NOW)).get("x1")?.closed, true); + }); + + test("a higher severity opens it again and says so, once", async () => { + const reminders = await settleSnoozes(present("x1", "critical", "disk is 97% full"), NOW); + assert.deepEqual(reminders.map((r) => [r.key, r.reason, r.severity, r.message]), [["k:x1", "worse", "critical", "disk is 97% full"]]); + assert.equal((await db.select().from(alertSnoozes)).length, 0); + assert.deepEqual(await settleSnoozes(present("x1", "critical"), NOW), [], "nothing more to say"); + }); + + test("gone for less than half an hour it stays closed; gone for longer it is forgotten, so the same problem later is new", async () => { + await db.delete(alertSnoozes); + await setClosed({ alertId: "x2", conditionKey: "k:x2", message: "m", severity: "warning", note: null, actor: "Olga" }, NOW); + await settleSnoozes([], new Date(NOW.getTime() + GONE_AFTER_MS - 60_000)); + assert.equal((await db.select().from(alertSnoozes)).length, 1); + await settleSnoozes([], new Date(NOW.getTime() + GONE_AFTER_MS + 60_000)); + assert.equal((await db.select().from(alertSnoozes)).length, 0); + }); + + test("a closed alert never expires like a snooze does, however much time passes while it is there", async () => { + await db.delete(alertSnoozes); + await setClosed({ alertId: "x3", conditionKey: "k:x3", message: "m", severity: "warning", note: null, actor: "Olga" }, NOW); + const tenYears = new Date(NOW.getTime() + 10 * 365 * 86_400_000); + assert.deepEqual(await settleSnoozes(present("x3", "warning"), tenYears), []); + assert.equal((await loadSnoozes(tenYears)).has("x3"), true); + }); + + test("messages about a closed alert are held back like a snoozed one's, and a snooze that ends still reminds as before", async () => { + await db.delete(alertSnoozes); + await setClosed({ alertId: "x4", conditionKey: "k:x4", message: "m", severity: "warning", note: null, actor: "Olga" }, NOW); + await setSnooze({ alertId: "x5", conditionKey: "k:x5", message: "snoozed one", until: new Date(NOW.getTime() + 120_000), actor: "Olga" }, NOW); + assert.deepEqual((await withoutSnoozed([{ key: "k:x4" }, { key: "k:other" }, { key: "k:x5" }], NOW)).map((i) => i.key), ["k:other"]); + const reminders = await settleSnoozes(present("x5", "warning", "snoozed one"), new Date(NOW.getTime() + 180_000)); + assert.deepEqual(reminders.map((r) => [r.key, r.reason]), [["k:x5", "ended"]]); + }); +}); diff --git a/server/test/rulesStorageSnooze.test.ts b/server/test/rulesStorageSnooze.test.ts index 28df5ce..21065fc 100644 --- a/server/test/rulesStorageSnooze.test.ts +++ b/server/test/rulesStorageSnooze.test.ts @@ -315,7 +315,7 @@ describe("rules, the Alerts page and the pages that show them", () => { const later = new Date(now.getTime() + 2 * 3600_000 + MIN); await setSnooze({ alertId: "backup:gone", conditionKey: "gone", message: "gone soon", until: new Date(now.getTime() + 3 * 3600_000), actor: "Olga" }, now); const reminders = await settleSnoozes([{ id: "disk:disk:server:1:/", message: "web: / is 96% full", severity: "warning", key: "disk:server:1:/" }], later); - assert.deepEqual(reminders, [{ key: "disk:server:1:/", message: "web: / is 96% full", severity: "warning" }]); + assert.deepEqual(reminders, [{ key: "disk:server:1:/", message: "web: / is 96% full", severity: "warning", reason: "ended" }]); assert.equal((await withoutSnoozed([{ key: "disk:server:1:/", message: "a" }], later)).length, 1); // One whose alert is gone, and has been for half an hour, is dropped quietly; the snooze ending for an alert that went is forgotten without a word. const muchLater = new Date(now.getTime() + 4 * 3600_000); diff --git a/web/src/api/client.ts b/web/src/api/client.ts index 4ef10c1..7f017b2 100644 --- a/web/src/api/client.ts +++ b/web/src/api/client.ts @@ -1914,6 +1914,8 @@ export interface AlertItem { flapping?: boolean; /** Snoozed until then: hidden like one under maintenance, and announced again if it is still there. */ snoozed?: { until: string; by: string }; + /** Closed by somebody: hidden with no end, until it gets worse or has been gone for half an hour. */ + closed?: { by: string; at: string; note: string | null }; } export type AlertRuleMetric = "cpu" | "mem" | "disk" | "disk_temp"; @@ -3185,6 +3187,8 @@ export const api = { ack: (data: AckInput) => request<{ ack: AlertAck }>("/api/alerts/ack", { method: "PUT", body: JSON.stringify(data) }), unack: (alertId: string) => request(`/api/alerts/ack?alertId=${encodeURIComponent(alertId)}`, { method: "DELETE" }), snooze: (alertId: string, until: string) => request<{ snooze: { until: string; snoozedBy: string } }>("/api/alerts/snooze", { method: "PUT", body: JSON.stringify({ alertId, until }) }), + close: (alertId: string, note: string | null) => request<{ closed: { by: string; at: string; note: string | null } }>("/api/alerts/close", { method: "PUT", body: JSON.stringify({ alertId, note }) }), + reopen: (alertId: string) => request(`/api/alerts/close?alertId=${encodeURIComponent(alertId)}`, { method: "DELETE" }), unsnooze: (alertId: string) => request(`/api/alerts/snooze?alertId=${encodeURIComponent(alertId)}`, { method: "DELETE" }), noise: (days: number) => request(`/api/alerts/noise?days=${days}`), }, diff --git a/web/src/components/CloseDrawer.tsx b/web/src/components/CloseDrawer.tsx new file mode 100644 index 0000000..b575d79 --- /dev/null +++ b/web/src/components/CloseDrawer.tsx @@ -0,0 +1,54 @@ +import { useState } from "react"; +import { api, type AlertItem } from "../api/client"; +import { readableError } from "../utils/errors"; +import { toast } from "../utils/toast"; +import DetailDrawer from "./DetailDrawer"; +import { ErrorNotice } from "./Notice"; + +/** + * "Close" an alert: it has been dealt with, or it is accepted. It is hidden — held back like one under maintenance, so not counted in the badges, the dashboard or the digest, and its + * messages are not sent — with no end. It comes back only if it **gets worse** (a more serious severity than it has now), or if the problem goes away for half an hour and returns + * (then it is a new one). The reason is written on its incident, so the history says why. Nothing about the thing itself is promised: that is what maintenance is for. + */ +export default function CloseDrawer({ alert, onClose, onSaved }: { alert: AlertItem; onClose: () => void; onSaved: () => void }) { + const [note, setNote] = useState(""); + const [busy, setBusy] = useState(false); + const [error, setError] = useState(null); + + async function close() { + setBusy(true); + setError(null); + try { + await api.alerts.close(alert.id, note.trim() === "" ? null : note.trim()); + toast.success("Closed."); + onSaved(); + onClose(); + } catch (err) { + setError(readableError(err)); + } finally { + setBusy(false); + } + } + + return ( + +
+ Hide it, with no end. It comes back only if it gets worse than {alert.severity}, or if the problem goes away for half an hour and then returns. Until then it is not counted and nothing is sent about it. The reason you give goes on its + incident. Nothing about the thing itself is promised — use Silence for planned work. +
+ + +