From 01acbaf8319142fe3c908e63fb2db00dfe45a038 Mon Sep 17 00:00:00 2001 From: Bobban Rydh Date: Wed, 4 Nov 2026 23:26:26 +0100 Subject: [PATCH] Add Hetzner Robot: dedicated servers and storage boxes, with shutting-down, locked and rescue-left-on alerts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Read every 15 minutes (Robot allows 200 requests an hour; read-only): each server's product, addresses, status, rescue system and paid-until, and the storage boxes. Adapter, sync service, hetzner_robot_state table, /api/hetzner-robot, Infrastructure → Hetzner Robot page, metrics and docs. Co-Authored-By: Claude Sonnet 5.5 --- DATABASE.md | 19 +- INTEGRATIONS.md | 15 +- README.md | 2 + ROLES.md | 2 + docs/MONITORING.md | 15 + docs/PROMETHEUS-GRAFANA.md | 4 + server/drizzle/0084_soft_ezekiel.sql | 8 + server/drizzle/meta/0084_snapshot.json | 8841 +++++++++++++++++ server/drizzle/meta/_journal.json | 7 + server/src/app.ts | 2 + server/src/db/schema.ts | 16 + server/src/index.ts | 2 + server/src/integrations/fieldSchemas.ts | 5 + .../src/integrations/hetznerRobot/adapter.ts | 179 + server/src/integrations/registry.ts | 3 + server/src/routes/hetznerRobot.ts | 43 + server/src/routes/integrations.ts | 4 + server/src/services/alerts.ts | 5 +- server/src/services/healthMonitor.ts | 26 +- server/src/services/hetznerRobotSync.ts | 210 + server/src/services/integrationGroups.ts | 2 +- server/src/services/maintenance.ts | 2 + server/src/services/metrics.ts | 32 +- server/test/hetznerRobot.test.ts | 394 + web/src/App.tsx | 2 + web/src/api/client.ts | 40 +- web/src/components/WallView.tsx | 1 + web/src/layout/nav.tsx | 2 + web/src/pages/HetznerRobot.tsx | 221 + web/src/utils/alertKinds.ts | 5 + web/src/utils/integrationTypes.ts | 6 +- 31 files changed, 10105 insertions(+), 10 deletions(-) create mode 100644 server/drizzle/0084_soft_ezekiel.sql create mode 100644 server/drizzle/meta/0084_snapshot.json create mode 100644 server/src/integrations/hetznerRobot/adapter.ts create mode 100644 server/src/routes/hetznerRobot.ts create mode 100644 server/src/services/hetznerRobotSync.ts create mode 100644 server/test/hetznerRobot.test.ts create mode 100644 web/src/pages/HetznerRobot.tsx diff --git a/DATABASE.md b/DATABASE.md index de111a1..6b22ab9 100644 --- a/DATABASE.md +++ b/DATABASE.md @@ -24,8 +24,8 @@ 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. | | **Writes** | SQLite lets one writer in at a time and refuses a second at once ("database is locked"). While a transaction of the app is open, its other writes wait for it ([`server/src/db/writeGate.ts`](server/src/db/writeGate.ts)) rather than being refused — a refused write also leaves its connection unable to commit the next transaction. Reads are never held; a wait over 10 seconds is given up. A lock held by *another* process (a backup tool reading the file, a second copy of the app) is still refused as before. | -| **Migrations** | SQL files in [`server/drizzle/`](server/drizzle) (`0000` … `0083`), applied automatically when the server starts. Which ones have run is recorded in the table `__drizzle_migrations`. | -| **Tables** | 92 application tables, plus drizzle's own `__drizzle_migrations`. | +| **Migrations** | SQL files in [`server/drizzle/`](server/drizzle) (`0000` … `0084`), applied automatically when the server starts. Which ones have run is recorded in the table `__drizzle_migrations`. | +| **Tables** | 93 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`. @@ -79,6 +79,7 @@ erDiagram integrations ||--o| fragnet_state : "cascade" integrations ||--o| arr_state : "cascade" integrations ||--o| download_state : "cascade" + integrations ||--o| hetzner_robot_state : "cascade" integrations ||--o| adguard_state : "cascade" integrations ||--o| technitium_state : "cascade" integrations ||--o| grafana_state : "cascade" @@ -1068,6 +1069,20 @@ How a qBittorrent or SABnzbd (an integration of type `qbittorrent` or `sabnzbd`) How the last read went is kept in `settings`, key `_internal:downloadsSync`. +#### `hetzner_robot_state` + +How a Hetzner Robot account (an integration of type `hetznerrobot`) is right now, one row each, replaced at every read (every fifteen minutes). `integration_id` is the primary key and a foreign key with **cascade**. There is no history: what is stored is the last good read, plus, for each server, since when its rescue system has been on and since when it has not been "ready" — which only this app can know, and which is carried from read to read by server number. + +| Column | Type | Notes | +|---|---|---| +| `integration_id` | integer PK | | +| `servers` | text NOT NULL, default `[]` | JSON: each dedicated server — number, name, addresses, product, data centre, traffic plan, status, cancelled, paid until, rescue system on (null when it could not be asked), `rescueSince`, `notReadySince`. | +| `storage_boxes` | text | JSON: each storage box — id, name, login, product, location, cancelled, locked, paid until, linked server. **Null when they could not be read.** | +| `skipped_detail` | integer NOT NULL, default 0 | How many servers were not asked about their rescue system (more than 25, to stay under Robot's request limit). | +| `updated_at` | text NOT NULL | ISO. | + +How the last read went is kept in `settings`, key `_internal:hetznerRobotSync`. + #### `adguard_state` How an AdGuard Home (an integration of type `adguard`) is right now, one row each, replaced at every read (every two minutes). `integration_id` is the primary key and a foreign key with **cascade**. No history: what is stored is the last good read, plus two clocks only this app can keep. diff --git a/INTEGRATIONS.md b/INTEGRATIONS.md index 6fe3c1e..033d1fe 100644 --- a/INTEGRATIONS.md +++ b/INTEGRATIONS.md @@ -15,7 +15,7 @@ the dashboard views themselves load fine. (UniFi, Nginx Proxy Manager, Home Assi ### Checking what an integration can read -On the Integrations page an administrator has an **Inspect** button on each integration that reads through the shared HTTP helper (Authentik, Immich, Jellyfin, NetBox, Nextcloud, Paperless-ngx, Prometheus, Hetzner Cloud, Speedtest Tracker, Fragnet, Sonarr, Radarr, Prowlarr, Lidarr, Readarr, qBittorrent, SABnzbd, AdGuard Home, Technitium DNS and Grafana). It runs the integration's reader once and shows: +On the Integrations page an administrator has an **Inspect** button on each integration that reads through the shared HTTP helper (Authentik, Immich, Jellyfin, NetBox, Nextcloud, Paperless-ngx, Prometheus, Hetzner Cloud, Hetzner Robot, Speedtest Tracker, Fragnet, Sonarr, Radarr, Prowlarr, Lidarr, Readarr, qBittorrent, SABnzbd, AdGuard Home, Technitium DNS and Grafana). It runs the integration's reader once and shows: - **what was asked** — each request, its path (with the *names* of the query parameters, not their values), the status, how long it took and how many bytes; - **what came back** — the *shape* of each JSON answer to three levels: the names of the fields and the kind of each (`string`, `number`, `array(12) of { … }`), with a `?` on a field that only some items of a list have. Never a value, never a token, so the report can be copied into a message; @@ -432,6 +432,19 @@ osTicket's API cannot close a ticket, so this is the one place in the app that * - **A wrong password is retried every five minutes**, and qBittorrent bans an address for an hour after a few wrong ones (*Web UI → Ban client after consecutive failures*). If the integration says it was refused with HTTP 403, fix the password and wait out the ban (or restart qBittorrent). - **Not verified against live installs** — the endpoints and fields are as the two applications' published API documentation has them, and the reader is tried against pretend ones. qBittorrent 5 renamed some states (`pausedDL` became `stoppedDL`); both are understood. SABnzbd's figures arrive as text, in megabytes and gigabytes, and are converted. Torrents are not paused, removed or added from here, and no NZB is added. +### Hetzner Robot + +- **Config fields:** the **webservice user name** (it looks like `#ws+abc123…`) and its **password** (stored encrypted), made in Hetzner Robot → Settings → Webservice and app settings. That is not the login to Robot itself. There is no address to give: Robot is always `https://robot-ws.your-server.de`. This is the *dedicated servers and storage boxes* side of Hetzner; the cloud servers are the **Hetzner Cloud** integration, with a project token. +- **Required access:** the webservice user, reachable from the app over HTTPS. HTTP Basic is sent with every request, and the app only ever sends GET requests. +- **What it does:** every **fifteen minutes** it reads `GET /server` (number, name, product, data centre, addresses, traffic plan, status, cancelled, paid until), `GET /server/{number}` for each server (whether its **rescue system** is on — it is not in the list) and `GET /storagebox` (product, location, cancelled, locked, paid until, the linked server). **Infrastructure → Hetzner Robot** shows them. Nothing is reset, nothing is activated, ordered or cancelled. + - **Fifteen minutes, and 25 servers:** Robot allows **200 requests an hour**, and a read is a list, one request per server and a list of storage boxes — so ten servers is 12 requests a read, 48 an hour. Only the first 25 servers (by number) are asked about their rescue system; any more are listed, counted on the page, and left without a rescue state. + - **Alerts** (source *Hetzner Robot*; held back by maintenance on the integration): a **server or storage box that is cancelled and ends within 30 days** (critical within 7; the date is the last day it runs, and the data goes with it); a **storage box that is locked** (critical); a **rescue system on for two hours** (the server's next boot is into the rescue system); a server **still "in process" a day** after the app first saw it so. See [MONITORING.md](docs/MONITORING.md#hetzner-robot). + - "Since when" (rescue on, not ready) is what this app saw: the time of the first read that showed it. + - If the account cannot be read for 45 minutes its alerts are neither raised nor cleared, the Alerts page says it could not check, and the integration is raised as failing like any other. A part that could not be read (the storage boxes, a server's rescue state) is shown as *could not be read*, never as none or off. + - `/metrics` has `homelab_hetzner_robot_servers`, `homelab_hetzner_robot_rescue_active`, `homelab_hetzner_robot_days_left` and `homelab_hetzner_robot_storage_box_locked`. +- **A wrong password is retried every fifteen minutes**, and Robot blocks an address for a while after a few wrong ones (HTTP 403). If the integration says it was refused, fix the password and wait. +- **Not verified against a live account** — the endpoints and fields are as Hetzner's published webservice documentation has them, and the reader is tried against a pretend one. An account with no servers (or no storage boxes) is answered with a 404 and a code ending in `NOT_FOUND`, read as none. Whether Robot switches the rescue system off by itself after a while is not known here, so the alert is for one that has been on two hours; traffic used is not read (Robot gives it per address, and the plan only). + ### Hetzner Cloud - **Config fields:** the project's **API token** (Hetzner Console → the project → Security → API tokens → *Generate API token*; stored encrypted). **Read** permission is enough — and recommended: the app only ever sends GET requests. A token belongs to **one project**, so add one integration for each project you want to watch. diff --git a/README.md b/README.md index 4e4ede4..91f1d8c 100644 --- a/README.md +++ b/README.md @@ -550,6 +550,8 @@ The page also shows the users, the files and the app updates waiting. Whether it **Hetzner Cloud** (Infrastructure → Hetzner Cloud). Add a project's read-only API token and the app lists its servers with their status, this month's traffic against the quota, backups, volumes and snapshots, and roughly what it costs a month. It warns when a server that was running is **off**, when one has used **80% of its traffic** (critical at 100%), when **rescue mode** is left on (the next reboot would not come back up), and when **backups** are enabled but late. A server that is also one the app knows by its agent gets a Hetzner card on its own page. It also lists **load balancers** (with the health of their targets), **floating IPs** and **certificates**, warns when a target is unhealthy, a certificate is about to end or a floating IP points at nothing, and **forecasts the month's traffic** ("at this rate web will pass its quota on 24 June"). Nothing at Hetzner is ever changed. See INTEGRATIONS.md and docs/MONITORING.md. +**Hetzner Robot** (Infrastructure → Hetzner Robot). Hetzner's dedicated servers and storage boxes — Robot is the other Hetzner, next to the Cloud. Add a webservice user (Robot → Settings → Webservice and app settings) and its password and the app lists the account's dedicated servers (product, data centre, addresses, traffic plan, status, whether the rescue system is on, and what is paid until or when a cancelled one shuts down) and its storage boxes. It warns when **a server or storage box is cancelled and about to shut down** (within 30 days; critical within 7 — the data goes with it), when **a storage box is locked**, when **a rescue system has been left on** (two hours — the next boot is into it) and when **a server is still "in process"** a day after it was first seen so. Nothing is reset, ordered or cancelled. See INTEGRATIONS.md and docs/MONITORING.md. + **Game servers** (Infrastructure → Game servers, for Fragnet's game panel). Add an account's API key and the app lists its game servers: the game, the IP addresses and ports (click one to copy it), whether each is running, its memory and disk against the plan, its backups, schedules and databases. It warns when a server's **newest backup is late** (7 days by default, or none at all — a server can be left out by name) and when **disk or memory is nearly full** (90% by default); a server that is merely stopped is not an alert, since game servers are often stopped on purpose. Operators can **start, stop, restart and kill** a server from the page (asked first, written to the audit log); nothing else at Fragnet is changed. Fragnet's panel is a fork of Pterodactyl, so the same integration reads any Pterodactyl panel (give its address). See INTEGRATIONS.md and docs/MONITORING.md. **Media managers** (Apps → Media managers). Add Sonarr, Radarr, Prowlarr, Lidarr and Readarr with their address and API key and the app shows, for each, what the application says is wrong with itself, its download queue (what is stuck or failed, and why), the disks it fills, how many wanted items have no file and, for Prowlarr, which indexers have failed. It warns when an application reports a **warning or error** (a download client that cannot be reached, indexers switched off), when **downloads have been stuck for two hours**, and when a **disk is nearly full**. Nothing is searched, grabbed or changed. See INTEGRATIONS.md and docs/MONITORING.md. diff --git a/ROLES.md b/ROLES.md index 21a5f0c..ab09a1a 100644 --- a/ROLES.md +++ b/ROLES.md @@ -27,6 +27,7 @@ page's own top-level link. | Synology | `/synology` | ✅ | ✅ | ✅ | | Docker | `/docker` | ✅ | ✅ | ✅ | | Hetzner Cloud | `/hetzner` | ✅ | ✅ | ✅ | +| Hetzner Robot | `/hetzner-robot` | ✅ | ✅ | ✅ | | Game servers | `/game-servers` | ✅ | ✅ | ✅ | | Tailscale | `/tailscale` | ✅ | ✅ | ✅ | | **Apps** | | | | | @@ -156,6 +157,7 @@ even further, to admin only: - **UPS** (Monitoring → UPS): everyone signed in sees each UPS, its history and what is on it; adding one (its address and SNMP community) is an administrator's job, like any integration, and what it powers is written in the dependency map. - **Endpoints**: everyone sees the checks and how they are doing; adding, changing and removing one is administrator-only (each makes the server connect somewhere); that includes the value a check judges and the header (a token) it sends, whose value is never shown again to anyone; *Check now* needs operator. +- **Hetzner Robot** (Infrastructure → Hetzner Robot, for dedicated servers and storage boxes): everyone signed in sees the servers, their addresses, rescue state and what is paid until; adding one (a webservice user and its password) is an administrator's job, like any integration. Nothing on the page resets, orders or cancels anything. - **Hetzner Cloud** (Infrastructure → Hetzner Cloud, and the card on a server's page): everyone signed in sees the servers, their addresses, traffic and cost estimate, volumes and snapshots; adding a project (its API token) is an administrator's job, like any integration. Nothing on the page changes anything at Hetzner. - **Game servers** (Infrastructure → Game servers, Fragnet): everyone signed in sees the servers, their games, addresses, use, backups and schedules; **start, stop, restart and kill** need operator (each is written to the audit log); adding the account (its API key) is an administrator's job, like any integration. - **Speedtest** (Monitoring → Speedtest): everyone signed in sees the speeds, their history and what is wrong; adding one (its address, an API token, and what the line is sold at) is an administrator's job, like any integration. Nothing here starts a speed test. diff --git a/docs/MONITORING.md b/docs/MONITORING.md index 4866a87..2b9d4d2 100644 --- a/docs/MONITORING.md +++ b/docs/MONITORING.md @@ -15,6 +15,7 @@ This page explains what Homelab Manager watches, how often, how a problem become - [Duplicati backups](#duplicati-backups) - [Nextcloud](#nextcloud) - [Hetzner Cloud](#hetzner-cloud) +- [Hetzner Robot](#hetzner-robot) - [Game servers (Fragnet)](#game-servers-fragnet) - [Media managers](#media-managers-sonarr-radarr-prowlarr) - [Download clients](#download-clients-qbittorrent-sabnzbd) @@ -149,6 +150,7 @@ Every threshold here is a default; where it can be changed, the place is named. | **Nextcloud can't be used / disk low** | The database needs upgrading (critical), maintenance mode is on, or little room is left for the data (critical under 5 GB) | on, with the integration | Nextcloud page; [below](#nextcloud) | | **Hetzner server off / traffic / rescue / backup** | A Hetzner Cloud server that was running is off, is stuck migrating or rebuilding, has used 80% of its month's traffic (critical at 100%), has rescue mode left on, or has backups enabled but none recent | on, with the integration | Hetzner page; [below](#hetzner-cloud) | | **Sonarr / Radarr / Prowlarr** | An application reports a health warning or error, has downloads stuck for two hours, or a disk under 10% free | on, with the integration | Media managers page; [below](#media-managers-sonarr-radarr-prowlarr) | +| **Hetzner Robot** | A dedicated server or storage box is cancelled and ends within 30 days (critical within 7), a storage box is locked (critical), a rescue system has been on for two hours, or a server is still "in process" after a day | on, with the integration | Hetzner Robot page; [below](#hetzner-robot) | | **qBittorrent / SABnzbd** | Downloads stuck (an error, or stalled for a day), qBittorrent without a network for 15 minutes, SABnzbd paused for six hours with work waiting or downloading nothing for an hour, or a download disk nearly full | on, with the integration | Download clients page; [below](#download-clients-qbittorrent-sabnzbd) | | **AdGuard Home** | DNS has not answered for ten minutes, or its DNS server is not running (critical); protection left off for an hour, or filter lists not updated for a week | on, with the integration | AdGuard Home page; [below](#adguard-home) | | **Technitium DNS** | DNS has not answered for ten minutes, or a secondary zone has expired (critical); a zone cannot sync, blocking left off for an hour, or block lists overdue for an update (warning) | on, with the integration | Technitium DNS page; [below](#technitium-dns) | @@ -292,6 +294,19 @@ Hetzner does not say when a server went off or when rescue mode was switched on, **On a server's page**, a *Hetzner Cloud* card appears when one of the project's servers is that server — matched by its public or private address, else by name — with its status, type, newest backup and traffic. A Hetzner server with no agent is listed as *not in the app's servers*. `/metrics` has `homelab_hetzner_server_running`, `homelab_hetzner_traffic_outgoing_bytes`, `homelab_hetzner_traffic_included_bytes` and `homelab_hetzner_monthly_cost`. +## Hetzner Robot + +An integration of type *Hetzner Robot* ([INTEGRATIONS.md](../INTEGRATIONS.md#hetzner-robot)) is one Hetzner account's dedicated servers and storage boxes, read every fifteen minutes (Robot allows 200 requests an hour), and **Infrastructure → Hetzner Robot** shows them: each server's product, data centre, addresses, traffic plan, status, rescue system and what is paid until (or, if cancelled, when it ends and how many days are left), and each storage box's product, location, linked server, whether it is locked and what is paid until. Nothing is reset, ordered or cancelled. + +| Alert | When | Severity | +|---|---|---| +| **Shutting down** | A server (or storage box) is **cancelled** and its last day is within **30 days**. The date Robot gives is the last day it runs; the server and its data go with it. Not-cancelled ones are never raised, however near their renewal | warning; critical within 7 days | +| **Storage box locked** | A storage box is locked — its data cannot be reached | critical | +| **Rescue system left on** | A server's rescue system has been switched on, in every read, for **two hours**: its next boot is into the rescue system, not its own | warning | +| **Stuck being set up** | A server has been something other than "ready" ("in process") in every read for **a day** | warning | + +"Since when" is what the app saw: the time of the first read that showed it, carried from read to read. Maintenance on the integration holds the alerts; a reading older than 45 minutes is not believed (they are neither raised nor cleared, and the Alerts page says it could not check). A server's rescue state that could not be asked is *unknown*, not off, and raises nothing. + ## Media managers (Sonarr, Radarr, Prowlarr) An integration of type *Sonarr*, *Radarr*, *Prowlarr*, *Lidarr* or *Readarr* ([INTEGRATIONS.md](../INTEGRATIONS.md#sonarr-radarr-and-prowlarr)) is read every five minutes, and **Apps → Media managers** shows, for each: what the application says is wrong with itself, its download queue (the stuck ones first, with why), its disks, how many wanted items have no file (Sonarr, Radarr) and, for Prowlarr, which indexers it has switched off after failures. Nothing is searched, grabbed or changed. diff --git a/docs/PROMETHEUS-GRAFANA.md b/docs/PROMETHEUS-GRAFANA.md index e8cf122..f103ba5 100644 --- a/docs/PROMETHEUS-GRAFANA.md +++ b/docs/PROMETHEUS-GRAFANA.md @@ -309,6 +309,10 @@ All gauges. The same table is checked by a test against what `/metrics` really s | `homelab_hetzner_traffic_forecast_bytes` | `project`, `server` | What a Hetzner Cloud server's outgoing traffic is forecast to come to by the end of the month; left out when there is too little to say. | | `homelab_hetzner_load_balancer_unhealthy_targets` | `project`, `load_balancer` | How many targets of a Hetzner Cloud load balancer are unhealthy. | | `homelab_hetzner_certificate_expiry_timestamp_seconds` | `project`, `certificate` | When a Hetzner Cloud certificate ends, in seconds since 1970. | +| `homelab_hetzner_robot_servers` | `name` | How many dedicated servers a Hetzner Robot account has. | +| `homelab_hetzner_robot_rescue_active` | `name`, `server`, `server_name` | 1 if a dedicated server's rescue system is on for the next boot, else 0; left out when it could not be asked. | +| `homelab_hetzner_robot_days_left` | `name`, `server`, `server_name` — or `storage_box`, `storage_box_name` | Calendar days left of a cancelled dedicated server or storage box: 0 on its last day, negative after. Only for cancelled ones. | +| `homelab_hetzner_robot_storage_box_locked` | `name`, `storage_box`, `storage_box_name` | 1 if a storage box is locked, else 0. | | `homelab_arr_health_issues` | `app`, `name` | How many warnings or errors Sonarr, Radarr or Prowlarr reports about itself. | | `homelab_arr_queue_items`, `homelab_arr_queue_stuck_items` | `app`, `name` | The downloads in the queue of Sonarr or Radarr, and how many are stuck (judged wrong, failed or blocked for two hours or more). | | `homelab_arr_wanted_missing` | `app`, `name` | Wanted items Sonarr or Radarr has no file for. | diff --git a/server/drizzle/0084_soft_ezekiel.sql b/server/drizzle/0084_soft_ezekiel.sql new file mode 100644 index 0000000..6571601 --- /dev/null +++ b/server/drizzle/0084_soft_ezekiel.sql @@ -0,0 +1,8 @@ +CREATE TABLE `hetzner_robot_state` ( + `integration_id` integer PRIMARY KEY NOT NULL, + `servers` text DEFAULT '[]' NOT NULL, + `storage_boxes` text, + `skipped_detail` integer DEFAULT 0 NOT NULL, + `updated_at` text NOT NULL, + FOREIGN KEY (`integration_id`) REFERENCES `integrations`(`id`) ON UPDATE no action ON DELETE cascade +); diff --git a/server/drizzle/meta/0084_snapshot.json b/server/drizzle/meta/0084_snapshot.json new file mode 100644 index 0000000..8118f1b --- /dev/null +++ b/server/drizzle/meta/0084_snapshot.json @@ -0,0 +1,8841 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "76493927-b828-4ef7-8cbf-4ebaec2500d4", + "prevId": "3329e6f4-7a98-428b-8122-110a97cd2d89", + "tables": { + "adguard_state": { + "name": "adguard_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 + }, + "running": { + "name": "running", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "protection_enabled": { + "name": "protection_enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "protection_off_since": { + "name": "protection_off_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dns_port": { + "name": "dns_port", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 53 + }, + "stats": { + "name": "stats", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "filters": { + "name": "filters", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "probe": { + "name": "probe", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "probe_fail_since": { + "name": "probe_fail_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "adguard_state_integration_id_integrations_id_fk": { + "name": "adguard_state_integration_id_integrations_id_fk", + "tableFrom": "adguard_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "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_kind_runbooks": { + "name": "alert_kind_runbooks", + "columns": { + "kind": { + "name": "kind", + "type": "text", + "primaryKey": true, + "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, + "default": "''" + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false, + "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": {}, + "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 + }, + "ticket_closed_at": { + "name": "ticket_closed_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ticket_closed_by": { + "name": "ticket_closed_by", + "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": {} + }, + "arr_state": { + "name": "arr_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 + }, + "health": { + "name": "health", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "queue": { + "name": "queue", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disks": { + "name": "disks", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "missing": { + "name": "missing", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "indexers": { + "name": "indexers", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "arr_state_integration_id_integrations_id_fk": { + "name": "arr_state_integration_id_integrations_id_fk", + "tableFrom": "arr_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_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": {} + }, + "cost_items": { + "name": "cost_items", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "period": { + "name": "period", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'Other'" + }, + "renews_on": { + "name": "renews_on", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "note": { + "name": "note", + "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": {} + }, + "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": {} + }, + "dockhand_vulnerabilities": { + "name": "dockhand_vulnerabilities", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "environment_id": { + "name": "environment_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "environment_name": { + "name": "environment_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "critical": { + "name": "critical", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "high": { + "name": "high", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "medium": { + "name": "medium", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "low": { + "name": "low", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "images_scanned": { + "name": "images_scanned", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "total_images": { + "name": "total_images", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "findings": { + "name": "findings", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "images": { + "name": "images", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "images_at": { + "name": "images_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "dockhand_vulnerabilities_integration_id_integrations_id_fk": { + "name": "dockhand_vulnerabilities_integration_id_integrations_id_fk", + "tableFrom": "dockhand_vulnerabilities", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "dockhand_vulnerabilities_integration_id_environment_id_pk": { + "columns": [ + "integration_id", + "environment_id" + ], + "name": "dockhand_vulnerabilities_integration_id_environment_id_pk" + } + }, + "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": {} + }, + "download_state": { + "name": "download_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 + }, + "speed_down": { + "name": "speed_down", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "speed_up": { + "name": "speed_up", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "paused": { + "name": "paused", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "connection": { + "name": "connection", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "counts": { + "name": "counts", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "total": { + "name": "total", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "items": { + "name": "items", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "failed": { + "name": "failed", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disks": { + "name": "disks", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "warnings": { + "name": "warnings", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "since": { + "name": "since", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "download_state_integration_id_integrations_id_fk": { + "name": "download_state_integration_id_integrations_id_fk", + "tableFrom": "download_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "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": {} + }, + "fragnet_state": { + "name": "fragnet_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "servers": { + "name": "servers", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "fragnet_state_integration_id_integrations_id_fk": { + "name": "fragnet_state_integration_id_integrations_id_fk", + "tableFrom": "fragnet_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "grafana_state": { + "name": "grafana_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 + }, + "rules": { + "name": "rules", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "datasources": { + "name": "datasources", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "grafana_state_integration_id_integrations_id_fk": { + "name": "grafana_state_integration_id_integrations_id_fk", + "tableFrom": "grafana_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "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": {} + }, + "hetzner_robot_state": { + "name": "hetzner_robot_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "servers": { + "name": "servers", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "storage_boxes": { + "name": "storage_boxes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "skipped_detail": { + "name": "skipped_detail", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "hetzner_robot_state_integration_id_integrations_id_fk": { + "name": "hetzner_robot_state_integration_id_integrations_id_fk", + "tableFrom": "hetzner_robot_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "hetzner_state": { + "name": "hetzner_state", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "servers": { + "name": "servers", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "volumes": { + "name": "volumes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "images": { + "name": "images", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "load_balancers": { + "name": "load_balancers", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "floating_ips": { + "name": "floating_ips", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "certificates": { + "name": "certificates", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "hetzner_state_integration_id_integrations_id_fk": { + "name": "hetzner_state_integration_id_integrations_id_fk", + "tableFrom": "hetzner_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "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 + }, + "core_update": { + "name": "core_update", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cron_state": { + "name": "cron_state", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cron_text": { + "name": "cron_text", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "setup_issues": { + "name": "setup_issues", + "type": "text", + "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": {} + }, + "port_presets": { + "name": "port_presets", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ports": { + "name": "ports", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "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": { + "port_presets_name_unique": { + "name": "port_presets_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "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": {} + }, + "release_cache": { + "name": "release_cache", + "columns": { + "repo": { + "name": "repo", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "published_at": { + "name": "published_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "checked_at": { + "name": "checked_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "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_container_ports": { + "name": "server_container_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'" + }, + "container": { + "name": "container", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "server_container_ports_unique": { + "name": "server_container_ports_unique", + "columns": [ + "server_id", + "port", + "protocol" + ], + "isUnique": true + } + }, + "foreignKeys": { + "server_container_ports_server_id_servers_id_fk": { + "name": "server_container_ports_server_id_servers_id_fk", + "tableFrom": "server_container_ports", + "tableTo": "servers", + "columnsFrom": [ + "server_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "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 + }, + "hostname_pinned": { + "name": "hostname_pinned", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "reported_hostname": { + "name": "reported_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": {} + }, + "speedtest_results": { + "name": "speedtest_results", + "columns": { + "integration_id": { + "name": "integration_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "result_id": { + "name": "result_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "download_bps": { + "name": "download_bps", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "upload_bps": { + "name": "upload_bps", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ping_ms": { + "name": "ping_ms", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "healthy": { + "name": "healthy", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "speedtest_results_at_idx": { + "name": "speedtest_results_at_idx", + "columns": [ + "integration_id", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "speedtest_results_integration_id_integrations_id_fk": { + "name": "speedtest_results_integration_id_integrations_id_fk", + "tableFrom": "speedtest_results", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "speedtest_results_integration_id_result_id_pk": { + "columns": [ + "integration_id", + "result_id" + ], + "name": "speedtest_results_integration_id_result_id_pk" + } + }, + "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": {} + }, + "technitium_state": { + "name": "technitium_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 + }, + "started_at": { + "name": "started_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dns_port": { + "name": "dns_port", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 53 + }, + "blocking_enabled": { + "name": "blocking_enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "blocking_off_since": { + "name": "blocking_off_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "settings": { + "name": "settings", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "stats": { + "name": "stats", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "zones": { + "name": "zones", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dhcp": { + "name": "dhcp", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "probe": { + "name": "probe", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "probe_fail_since": { + "name": "probe_fail_since", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "technitium_state_integration_id_integrations_id_fk": { + "name": "technitium_state_integration_id_integrations_id_fk", + "tableFrom": "technitium_state", + "tableTo": "integrations", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "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 + }, + "server_page_layout": { + "name": "server_page_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 ca6178d..583ad5c 100644 --- a/server/drizzle/meta/_journal.json +++ b/server/drizzle/meta/_journal.json @@ -589,6 +589,13 @@ "when": 1793829376092, "tag": "0083_lovely_midnight", "breakpoints": true + }, + { + "idx": 84, + "version": "6", + "when": 1793830559784, + "tag": "0084_soft_ezekiel", + "breakpoints": true } ] } \ No newline at end of file diff --git a/server/src/app.ts b/server/src/app.ts index 9baf370..dbbe295 100644 --- a/server/src/app.ts +++ b/server/src/app.ts @@ -74,6 +74,7 @@ import { wallRouter } from "./routes/wall.js"; import { adguardRouter } from "./routes/adguard.js"; import { technitiumRouter } from "./routes/technitium.js"; import { downloadsRouter } from "./routes/downloads.js"; +import { hetznerRobotRouter } from "./routes/hetznerRobot.js"; import { grafanaRouter } from "./routes/grafana.js"; import { versionsRouter } from "./routes/versions.js"; import { portPresetsRouter } from "./routes/portPresets.js"; @@ -229,6 +230,7 @@ export function createApp() { app.use("/api/adguard", adguardRouter); app.use("/api/technitium", technitiumRouter); app.use("/api/downloads", downloadsRouter); + app.use("/api/hetzner-robot", hetznerRobotRouter); app.use("/api/grafana", grafanaRouter); app.use("/api/versions", versionsRouter); app.use("/api/port-presets", portPresetsRouter); diff --git a/server/src/db/schema.ts b/server/src/db/schema.ts index 82f4ce3..6cb350a 100644 --- a/server/src/db/schema.ts +++ b/server/src/db/schema.ts @@ -580,6 +580,7 @@ export const integrationTypes = [ "readarr", "qbittorrent", "sabnzbd", + "hetznerrobot", ] as const; export type IntegrationType = (typeof integrationTypes)[number]; @@ -1392,6 +1393,21 @@ export const downloadState = sqliteTable("download_state", { updatedAt: text("updated_at").notNull(), // ISO }); +// ─── Hetzner Robot ────────────────────────────────────────────────────────── + +// How a Hetzner Robot account (an integration of type "hetznerrobot") is right now, one row each, replaced at every read: its dedicated servers (each with since when its rescue system has been on and +// since when it has not been "ready", which only this app can know) and its storage boxes. A column that is null could not be read, which is not the same as none. Read by +// services/hetznerRobotSync.ts. +export const hetznerRobotState = sqliteTable("hetzner_robot_state", { + integrationId: integer("integration_id") + .primaryKey() + .references(() => integrations.id, { onDelete: "cascade" }), + servers: text("servers").notNull().default("[]"), // JSON: the dedicated servers, with rescueSince and notReadySince carried from read to read + storageBoxes: text("storage_boxes"), // JSON; null: could not be read + skippedDetail: integer("skipped_detail").notNull().default(0), // servers not asked about their rescue system (too many for Robot's request limit) + updatedAt: text("updated_at").notNull(), // ISO +}); + // ─── AdGuard Home ─────────────────────────────────────────────────────────── // How an AdGuard Home (an integration of type "adguard") is right now, one row each, replaced at every read: whether its DNS server runs and protects, the statistics, its filter lists and the result diff --git a/server/src/index.ts b/server/src/index.ts index 2bcbe70..93709c5 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -45,6 +45,7 @@ import { initArrSync } from "./services/arrSync.js"; import { initAdguardSync } from "./services/adguardSync.js"; import { initTechnitiumSync } from "./services/technitiumSync.js"; import { initDownloadsSync } from "./services/downloadsSync.js"; +import { initHetznerRobotSync } from "./services/hetznerRobotSync.js"; import { initGrafanaSync } from "./services/grafanaSync.js"; import { initVersionCheck } from "./services/appVersions.js"; import { backfillMetricRollups } from "./services/serverMetrics.js"; @@ -113,6 +114,7 @@ initArrSync(); initAdguardSync(); initTechnitiumSync(); initDownloadsSync(); +initHetznerRobotSync(); initGrafanaSync(); initVersionCheck(); // The hourly and daily figures are built from what is already kept, once, the first time after they were added (in the background: nothing waits for it). diff --git a/server/src/integrations/fieldSchemas.ts b/server/src/integrations/fieldSchemas.ts index b100eda..637b6b8 100644 --- a/server/src/integrations/fieldSchemas.ts +++ b/server/src/integrations/fieldSchemas.ts @@ -116,6 +116,10 @@ export const INTEGRATION_FIELDS: Partial> = { tailscale: "https://api.tailscale.com", hetzner: "https://api.hetzner.cloud", + hetznerrobot: "https://robot-ws.your-server.de", fragnet: "https://panel.fragnet.net", }; diff --git a/server/src/integrations/hetznerRobot/adapter.ts b/server/src/integrations/hetznerRobot/adapter.ts new file mode 100644 index 0000000..2d63620 --- /dev/null +++ b/server/src/integrations/hetznerRobot/adapter.ts @@ -0,0 +1,179 @@ +/** + * Hetzner Robot adapter — Hetzner's dedicated servers and storage boxes (Robot is the other Hetzner, next to the Cloud). Config: user and password of a **webservice user** (Robot → Settings → + * Webservice and app settings; not the login to Robot itself), sent as HTTP Basic to `https://robot-ws.your-server.de`. + * + * Reading only: the account's dedicated servers (number, name, product, data centre, addresses, traffic plan, status, whether it is cancelled and until when, and — by asking for each one — whether the + * rescue system is switched on) and its storage boxes (product, location, whether cancelled or locked, until when it is paid). Nothing is sent to Robot but GET requests: no server is reset, no rescue + * system is activated, nothing is ordered or cancelled. + * + * Robot allows 200 requests an hour, so a read is a list, one request for each server (at most MAX_DETAIL of them) and a list of storage boxes. Endpoints and field names are from Robot's published + * webservice documentation (`/server`, `/server/{number}`, `/storagebox`; each list entry wrapped in an object of its own kind) and have not been checked against a live account here; every field is read + * defensively. A list with nothing in it is answered with a 404 and a code ending in NOT_FOUND, which is read as "none". + */ +import { requestJson } from "../httpJson.js"; +import { withDiagLogging } from "../../services/diagLog.js"; + +export interface HetznerRobotConfig { + user: string; + password: string; + /** Only for tests: the form never asks for it (a request cannot set it — see fieldSchemas.ts). */ + apiUrl?: string; +} + +export interface RobotServer { + number: number; + name: string; + ip: string | null; + ipv6: string | null; + product: string | null; + /** The data centre ("FSN1-DC14"). */ + dc: string | null; + /** The traffic plan as Robot words it ("unlimited", "20 TB"). */ + traffic: string | null; + /** "ready", or "in process" while it is being set up. */ + status: string; + cancelled: boolean; + /** The date it is paid until, "YYYY-MM-DD"; for a cancelled server, the day it shuts down. */ + paidUntil: string | null; + /** Whether the rescue system is switched on for the next boot; null when it could not be asked. */ + rescue: boolean | null; +} + +export interface RobotStorageBox { + id: number; + name: string; + login: string | null; + product: string | null; + location: string | null; + cancelled: boolean; + locked: boolean; + paidUntil: string | null; + /** The number of the server it is linked to, when it is. */ + linkedServer: number | null; +} + +export interface RobotRead { + servers: RobotServer[]; + /** Null when the storage boxes could not be read (which is not the same as having none). */ + storageBoxes: RobotStorageBox[] | null; + /** How many servers were not asked about their rescue system, for being more than MAX_DETAIL. */ + skippedDetail: number; +} + +export interface HetznerRobotAdapter { + ping(): Promise<{ ok: boolean; latencyMs?: number; error?: string }>; + read(): Promise; +} + +const API = "https://robot-ws.your-server.de"; +/** Robot allows 200 requests an hour: a read asks about at most this many servers one by one. */ +export const MAX_DETAIL = 25; + +const obj = (v: unknown): Record => (v !== null && typeof v === "object" && !Array.isArray(v) ? (v as Record) : {}); +const arr = (v: unknown): unknown[] => (Array.isArray(v) ? v : []); +const str = (v: unknown): string | null => (typeof v === "string" && v.trim() !== "" ? v.trim() : null); +const num = (v: unknown): number | null => (typeof v === "number" && Number.isFinite(v) ? v : typeof v === "string" && v.trim() !== "" && Number.isFinite(Number(v)) ? Number(v) : null); +/** A date ("2026-12-01", or with a time) as "YYYY-MM-DD"; null for anything else. */ +const day = (v: unknown): string | null => { + const s = str(v); + return s !== null && /^\d{4}-\d{2}-\d{2}/.test(s) && Number.isFinite(Date.parse(s.slice(0, 10))) ? s.slice(0, 10) : null; +}; + +/** Pure: one entry of `/server` or the answer of `/server/{number}` — wrapped in `{ server: {…} }`, or not. */ +export function parseServer(raw: unknown): RobotServer | null { + const o = obj(raw); + const s = obj(o.server ?? raw); + const number = num(s.server_number); + if (number === null) return null; + const rescue = s.rescue; + return { + number, + name: str(s.server_name) ?? str(s.product) ?? `Server ${number}`, + ip: str(s.server_ip), + ipv6: str(s.server_ipv6_net), + product: str(s.product), + dc: str(s.dc), + traffic: str(s.traffic), + status: str(s.status)?.toLowerCase() ?? "unknown", + cancelled: s.cancelled === true, + paidUntil: day(s.paid_until), + rescue: typeof rescue === "boolean" ? rescue : null, + }; +} + +/** Pure: one entry of `/storagebox`, wrapped in `{ storagebox: {…} }` or not. */ +export function parseStorageBox(raw: unknown): RobotStorageBox | null { + const o = obj(raw); + const s = obj(o.storagebox ?? raw); + const id = num(s.id); + if (id === null) return null; + return { + id, + name: str(s.name) ?? str(s.login) ?? `Storage box ${id}`, + login: str(s.login), + product: str(s.product), + location: str(s.location), + cancelled: s.cancelled === true, + locked: s.locked === true, + paidUntil: day(s.paid_until), + linkedServer: num(s.linked_server), + }; +} + +export function createHetznerRobotAdapter(config: HetznerRobotConfig): HetznerRobotAdapter { + const base = String(config.apiUrl ?? API).replace(/\/+$/, ""); + const auth = `Basic ${Buffer.from(`${String(config.user ?? "").trim()}:${String(config.password ?? "")}`).toString("base64")}`; + + /** Asks for something; a list that is empty is answered with a 404 and NOT_FOUND in its code, and `emptyOk` reads that as an empty list. */ + async function get(path: string, emptyOk = false): Promise { + const res = await requestJson(`${base}${path}`, { headers: { Authorization: auth, Accept: "application/json" } }); + const error = obj(obj(res.json).error); + const code = str(error.code); + if (res.status === 401) throw new Error("Hetzner Robot did not accept the user name and password (HTTP 401) — use the webservice user of Robot → Settings → Webservice and app settings, not the login to Robot itself"); + if (res.status === 403) throw new Error(`Hetzner Robot refused the request (HTTP 403${code ? `, ${code}` : ""}) — it blocks an address for a while after wrong passwords or more than 200 requests in an hour; wait, then check the webservice user`); + if (res.status === 404 && emptyOk && code !== null && /NOT_FOUND$/.test(code)) return []; + if (res.status === 404) throw new Error(`Hetzner Robot has no such address (HTTP 404${code ? `, ${code}` : ""})`); + if (res.status < 200 || res.status >= 300) throw new Error(`Hetzner Robot error: HTTP ${res.status}${code ? ` (${code})` : ""}${str(error.message) ? ` — ${str(error.message)}` : ""}`); + if (res.json === null) throw new Error("Hetzner Robot answered with something that isn't JSON"); + return res.json; + } + + async function read(): Promise { + // The list of servers must work: it is what says the account is there. + const listed = arr(await get("/server", true)).map(parseServer).filter((s): s is RobotServer => s !== null); + const servers = [...listed].sort((a, b) => a.number - b.number); + const asked = servers.slice(0, MAX_DETAIL); + // The rescue system is not in the list: ask about each server, a few at a time. + for (let i = 0; i < asked.length; i += 4) { + await Promise.all( + asked.slice(i, i + 4).map(async (s) => { + try { + const detail = parseServer(await get(`/server/${s.number}`)); + s.rescue = detail?.rescue ?? null; + } catch { + s.rescue = null; + } + }), + ); + } + let storageBoxes: RobotStorageBox[] | null = null; + try { + storageBoxes = arr(await get("/storagebox", true)).map(parseStorageBox).filter((b): b is RobotStorageBox => b !== null).sort((a, b) => a.id - b.id); + } catch { + storageBoxes = null; + } + return { servers, storageBoxes, skippedDetail: Math.max(0, servers.length - asked.length) }; + } + + async function ping(): Promise<{ ok: boolean; latencyMs?: number; error?: string }> { + const start = Date.now(); + try { + await get("/server", true); + return { ok: true, latencyMs: Date.now() - start }; + } catch (err) { + return { ok: false, error: err instanceof Error ? err.message : String(err) }; + } + } + + return withDiagLogging("hetznerrobot", { ping, read }); +} diff --git a/server/src/integrations/registry.ts b/server/src/integrations/registry.ts index 87e9853..c16ac40 100644 --- a/server/src/integrations/registry.ts +++ b/server/src/integrations/registry.ts @@ -22,6 +22,7 @@ import { createPaperlessAdapter } from "./paperless/adapter.js"; import { createN8nAdapter } from "./n8n/adapter.js"; import { createNetBoxAdapter } from "./netbox/adapter.js"; import { createHetznerAdapter } from "./hetzner/adapter.js"; +import { createHetznerRobotAdapter } from "./hetznerRobot/adapter.js"; import { createSpeedtestAdapter } from "./speedtest/adapter.js"; import { createFragnetAdapter } from "./fragnet/adapter.js"; import { createArrAdapter } from "./arr/adapter.js"; @@ -88,6 +89,8 @@ export function createIntegrationAdapter(type: IntegrationType, config: Integrat return createSpeedtestAdapter(config as any); case "hetzner": return createHetznerAdapter(config as any); + case "hetznerrobot": + return createHetznerRobotAdapter(config as any); case "fragnet": return createFragnetAdapter(config as any); case "sonarr": diff --git a/server/src/routes/hetznerRobot.ts b/server/src/routes/hetznerRobot.ts new file mode 100644 index 0000000..85a6199 --- /dev/null +++ b/server/src/routes/hetznerRobot.ts @@ -0,0 +1,43 @@ +import { Router } from "express"; +import { eq } from "drizzle-orm"; +import { db } from "../db/client.js"; +import { hetznerRobotState, integrations } from "../db/schema.js"; +import { requireAuth } from "../auth/middleware.js"; +import { daysLeft, isRobotFresh, robotProblems, robotSyncStatuses, storedOf } from "../services/hetznerRobotSync.js"; +import { asyncHandler } from "../utils/asyncHandler.js"; + +export const hetznerRobotRouter = Router(); +hetznerRobotRouter.use(requireAuth); + +/** Every Hetzner Robot account, how it is, from what the last reads stored: its dedicated servers (rescue system, cancellation), its storage boxes and what is wrong. Everyone signed in can see it. Nothing here changes anything at Hetzner. */ +hetznerRobotRouter.get("/", asyncHandler(async (_req, res) => { + const [rows, states, statuses] = await Promise.all([ + db.select({ id: integrations.id, name: integrations.name, enabled: integrations.enabled }).from(integrations).where(eq(integrations.type, "hetznerrobot")).orderBy(integrations.name), + db.select().from(hetznerRobotState), + robotSyncStatuses(), + ]); + const byId = new Map(states.map((s) => [s.integrationId, s])); + const now = Date.now(); + res.json({ + accounts: rows.map((r) => { + const row = byId.get(r.id); + const state = row ? storedOf(row) : null; + const status = statuses[r.id] ?? null; + const fresh = isRobotFresh(status ?? undefined, now); + return { + id: r.id, + name: r.name, + enabled: r.enabled, + status, + fresh, + state: state && { + ...state, + /** Calendar days to the end of each cancelled server and storage box: 0 on the day it ends, negative after. */ + serverDays: Object.fromEntries(state.servers.filter((s) => s.cancelled).map((s) => [s.number, daysLeft(s.paidUntil, now)])), + boxDays: Object.fromEntries((state.storageBoxes ?? []).filter((b) => b.cancelled).map((b) => [b.id, daysLeft(b.paidUntil, now)])), + }, + problems: state && fresh ? robotProblems(r.id, r.name, state, now) : [], + }; + }), + }); +})); diff --git a/server/src/routes/integrations.ts b/server/src/routes/integrations.ts index 029fa87..915683d 100644 --- a/server/src/routes/integrations.ts +++ b/server/src/routes/integrations.ts @@ -45,6 +45,7 @@ import { ARR_KINDS } from "../integrations/arr/adapter.js"; import { forgetAdguard, syncAdguard } from "../services/adguardSync.js"; import { forgetDownload, syncDownload } from "../services/downloadsSync.js"; import { DOWNLOAD_KINDS } from "../integrations/downloads/adapter.js"; +import { forgetRobot, syncRobot } from "../services/hetznerRobotSync.js"; import { forgetTechnitium, syncTechnitium } from "../services/technitiumSync.js"; import { forgetGrafana, syncGrafana } from "../services/grafanaSync.js"; import { forgetNextcloud, syncNextcloud } from "../services/nextcloudSync.js"; @@ -163,6 +164,7 @@ integrationsRouter.post("/", requireRole("admin"), asyncHandler(async (req, res) if (type === "fragnet") void syncFragnet(created.id).then(() => invalidateAlertsCache()); if ((ARR_KINDS as string[]).includes(type)) void syncArr(created.id).then(() => invalidateAlertsCache()); if ((DOWNLOAD_KINDS as string[]).includes(type)) void syncDownload(created.id).then(() => invalidateAlertsCache()); + if (type === "hetznerrobot") void syncRobot(created.id).then(() => invalidateAlertsCache()); if (type === "adguard") void syncAdguard(created.id).then(() => invalidateAlertsCache()); if (type === "technitium") void syncTechnitium(created.id).then(() => invalidateAlertsCache()); if (type === "grafana") void syncGrafana(created.id).then(() => invalidateAlertsCache()); @@ -283,6 +285,7 @@ integrationsRouter.patch("/:id", requireRole("admin"), asyncHandler(async (req, if (updated.type === "fragnet" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncFragnet(updated.id).then(() => invalidateAlertsCache()); if ((ARR_KINDS as string[]).includes(updated.type) && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncArr(updated.id).then(() => invalidateAlertsCache()); if ((DOWNLOAD_KINDS as string[]).includes(updated.type) && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncDownload(updated.id).then(() => invalidateAlertsCache()); + if (updated.type === "hetznerrobot" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncRobot(updated.id).then(() => invalidateAlertsCache()); if (updated.type === "adguard" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncAdguard(updated.id).then(() => invalidateAlertsCache()); if (updated.type === "technitium" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncTechnitium(updated.id).then(() => invalidateAlertsCache()); if (updated.type === "grafana" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncGrafana(updated.id).then(() => invalidateAlertsCache()); @@ -410,6 +413,7 @@ integrationsRouter.delete("/:id", requireRole("admin"), asyncHandler(async (req, if (existing.type === "fragnet") await forgetFragnet(id); if ((ARR_KINDS as string[]).includes(existing.type)) await forgetArr(id); if ((DOWNLOAD_KINDS as string[]).includes(existing.type)) await forgetDownload(id); + if (existing.type === "hetznerrobot") await forgetRobot(id); if (existing.type === "adguard") await forgetAdguard(id); if (existing.type === "technitium") await forgetTechnitium(id); if (existing.type === "grafana") await forgetGrafana(id); diff --git a/server/src/services/alerts.ts b/server/src/services/alerts.ts index d4aab50..725baa0 100644 --- a/server/src/services/alerts.ts +++ b/server/src/services/alerts.ts @@ -91,6 +91,7 @@ const SOURCES: Record = { lidarr: { label: "Lidarr", link: "/media" }, readarr: { label: "Readarr", link: "/media" }, prowlarr: { label: "Prowlarr", link: "/media" }, + hetznerrobot: { label: "Hetzner Robot", link: "/hetzner-robot" }, qbittorrent: { label: "qBittorrent", link: "/downloads" }, sabnzbd: { label: "SABnzbd", link: "/downloads" }, adguard: { label: "AdGuard Home", link: "/adguard" }, @@ -149,6 +150,8 @@ function originOfConditionKey(key: string): { type: string; id: number | null; c if (m) return { type: "grafana", id: Number(m[2]), category: m[1] === "ds" ? "integration" : "monitoring" }; m = /^(sonarr|radarr|prowlarr|lidarr|readarr)-(health|queue|disk):(\d+)/.exec(key); if (m) return { type: m[1], id: Number(m[3]), category: m[2] === "disk" ? "disk" : "services" }; + m = /^hetznerrobot-(ending|rescue|setup|boxlocked|boxending):(\d+):/.exec(key); + if (m) return { type: "hetznerrobot", id: Number(m[2]), category: "services" }; m = /^(qbittorrent|sabnzbd)-(stuck|connection|paused|stalled|disk):(\d+)/.exec(key); if (m) return { type: m[1], id: Number(m[3]), category: m[2] === "disk" ? "disk" : "services" }; m = /^fragnet-(disk|memory|backup):(\d+):/.exec(key); @@ -305,7 +308,7 @@ export async function collectAlerts(): Promise { if (held.has("slo")) cannotCheck("Service-level targets", "couldn't be judged — see the server log", "Server and storage health"); if (held.has("server:baseline")) cannotCheck("What is usual for the time", "couldn't be judged — see the server log", "Server and storage health"); for (const h of held) { - const m = /^(proxmox|synology|unifi|ups|dockhand|jellyfin|authentik|prometheus|immich|paperless|nextcloud|netbox|n8n|hetzner|speedtest|fragnet|sonarr|radarr|prowlarr|lidarr|readarr|qbittorrent|sabnzbd|adguard|technitium|grafana):(\d+)(?::(.+))?$/.exec(h); + const m = /^(proxmox|synology|unifi|ups|dockhand|jellyfin|authentik|prometheus|immich|paperless|nextcloud|netbox|n8n|hetzner|hetznerrobot|speedtest|fragnet|sonarr|radarr|prowlarr|lidarr|readarr|qbittorrent|sabnzbd|adguard|technitium|grafana):(\d+)(?::(.+))?$/.exec(h); if (!m || (m[3] && held.has(`${m[1]}:${m[2]}`))) continue; const row = intById.get(Number(m[2])); cannotCheck(`${SOURCES[m[1]].label} “${row?.name ?? `#${m[2]}`}”${m[3] === "vuln" ? " (vulnerability scans)" : m[3] === "images" ? " (age of the images)" : m[3] ? ` (node ${m[3]})` : ""}`, "couldn't be read — see the Diagnostic Log", "Server and storage health"); diff --git a/server/src/services/healthMonitor.ts b/server/src/services/healthMonitor.ts index 10dd1fc..4519bf8 100644 --- a/server/src/services/healthMonitor.ts +++ b/server/src/services/healthMonitor.ts @@ -1,6 +1,6 @@ import { and, eq, inArray } from "drizzle-orm"; import { db } from "../db/client.js"; -import { downloadState, technitiumState, authentikState, n8nState, netboxState, nextcloudState, paperlessState, immichState, prometheusState, integrations, jellyfinState, networkDevices, serverPorts, servers, upsState , dockhandVulnerabilities , hetznerState , fragnetState , arrState , adguardState , grafanaState } from "../db/schema.js"; +import { hetznerRobotState, downloadState, technitiumState, authentikState, n8nState, netboxState, nextcloudState, paperlessState, immichState, prometheusState, integrations, jellyfinState, networkDevices, serverPorts, servers, upsState , dockhandVulnerabilities , hetznerState , fragnetState , arrState , adguardState , grafanaState } from "../db/schema.js"; import { loadIntegrationConfig } from "../integrations/loadIntegration.js"; import { createProxmoxAdapter, type ProxmoxNodeStats } from "../integrations/proxmox/adapter.js"; import { createSynologyAdapter, type SynologyStorageInfo } from "../integrations/synology/adapter.js"; @@ -40,6 +40,7 @@ import { isTechnitiumFresh, storedOf as technitiumStoredOf, technitiumProblems, import { grafanaProblems, grafanaSyncStatuses, isGrafanaFresh, storedOf as grafanaStoredOf, type GrafanaProblem } from "./grafanaSync.js"; import { arrProblems, arrSyncStatuses, isArrFresh, storedOf as arrStoredOf, type ArrProblem } from "./arrSync.js"; import { DOWNLOAD_KINDS, type DownloadKind } from "../integrations/downloads/adapter.js"; +import { isRobotFresh, robotProblems, robotSyncStatuses, storedOf as robotStoredOf, type RobotProblem } from "./hetznerRobotSync.js"; import { downloadProblems, downloadSyncStatuses, isDownloadFresh, storedOf as downloadStoredOf, type DownloadProblem } from "./downloadsSync.js"; import { fragnetProblems, fragnetSyncStatuses, isFragnetFresh, optionsOf as fragnetOptions, serversOf as fragnetServersOf, type FragnetProblem } from "./fragnetSync.js"; import { evaluateContainers, loadContainerMemory, saveContainerMemory, type ContainerMemory, type DockerSnapshot } from "./containerHealth.js"; @@ -144,6 +145,8 @@ export interface HealthSnapshot { arr?: { integrationId: number; kind: ArrKind; problems: ArrProblem[] }[]; /** What is wrong with each qBittorrent and SABnzbd (downloads that are stuck, no connection, a queue left paused or getting nothing, a disk nearly full), only while that reading is recent (services/downloadsSync.ts). */ downloads?: { integrationId: number; kind: DownloadKind; problems: DownloadProblem[] }[]; + /** What is wrong with each Hetzner Robot account (a server or storage box about to shut down, a locked storage box, a rescue system left on, a server stuck being set up), only while that reading is recent (services/hetznerRobotSync.ts). */ + hetznerRobot?: { integrationId: number; problems: RobotProblem[] }[]; /** What is wrong with each AdGuard Home (DNS not running or not answering, protection left off, filter lists not updating), only while that reading is recent (services/adguardSync.ts). */ adguard?: { integrationId: number; problems: AdguardProblem[] }[]; /** What is wrong with each Technitium DNS Server (DNS not answering, blocking left off, block lists not updating, zones expired or not syncing), only while that reading is recent (services/technitiumSync.ts). */ @@ -301,6 +304,9 @@ export function evaluateHealth(snapshot: HealthSnapshot, thresholds: Thresholds, for (const t of snapshot.technitium ?? []) for (const p of t.problems) out.push({ key: p.key, source: `technitium:${t.integrationId}`, message: p.message, severity: p.severity }); for (const g of snapshot.grafana ?? []) for (const p of g.problems) out.push({ key: p.key, source: `grafana:${g.integrationId}`, message: p.message, severity: p.severity }); + // Hetzner Robot: servers and storage boxes about to shut down, a locked storage box, a rescue system left on, a server stuck being set up. + for (const r of snapshot.hetznerRobot ?? []) for (const p of r.problems) out.push({ key: p.key, source: `hetznerrobot:${r.integrationId}`, message: p.message, severity: p.severity }); + // qBittorrent and SABnzbd: downloads that are stuck, no connection, a queue left paused or getting nothing, disks nearly full. for (const d of snapshot.downloads ?? []) for (const p of d.problems) out.push({ key: p.key, source: `${d.kind}:${d.integrationId}`, message: p.message, severity: p.severity }); @@ -693,6 +699,24 @@ export async function collectSnapshot(): Promise<{ snapshot: HealthSnapshot; hel console.error("[health] couldn't judge Sonarr, Radarr and Prowlarr:", err instanceof Error ? err.message : err); } + // Hetzner Robot: read by its own pass every fifteen minutes; what is judged is what that pass stored, and only while it is recent. + try { + const rowsH = await db.select({ id: integrations.id, name: integrations.name }).from(integrations).where(and(eq(integrations.type, "hetznerrobot"), eq(integrations.enabled, true))); + if (rowsH.length > 0) { + const statuses = await robotSyncStatuses(); + for (const r of rowsH) { + const [state] = await db.select().from(hetznerRobotState).where(eq(hetznerRobotState.integrationId, r.id)).limit(1); + if (!state || !isRobotFresh(statuses[r.id], Date.now())) { + held.add(`hetznerrobot:${r.id}`); + continue; + } + (snapshot.hetznerRobot ??= []).push({ integrationId: r.id, problems: robotProblems(r.id, r.name, robotStoredOf(state), Date.now()) }); + } + } + } catch (err) { + console.error("[health] couldn't judge Hetzner Robot:", err instanceof Error ? err.message : err); + } + // qBittorrent and SABnzbd: read by their own pass every five minutes; what is judged is what that pass stored, and only while it is recent. try { const rowsD = await db.select({ id: integrations.id, name: integrations.name, type: integrations.type }).from(integrations).where(and(inArray(integrations.type, DOWNLOAD_KINDS), eq(integrations.enabled, true))); diff --git a/server/src/services/hetznerRobotSync.ts b/server/src/services/hetznerRobotSync.ts new file mode 100644 index 0000000..bcc64b6 --- /dev/null +++ b/server/src/services/hetznerRobotSync.ts @@ -0,0 +1,210 @@ +/** + * Keeps what Hetzner Robot says up to date: every fifteen minutes each Robot integration is read — its dedicated servers (and whether each one's rescue system is on) and its storage boxes — and the + * state is stored. Pages and alerts are built from what is stored. (Fifteen minutes, not five: Robot allows 200 requests an hour and a read asks about each server.) + * + * What is raised: **a server or storage box that is cancelled and about to shut down** (warning within 30 days, critical within 7 — the date Robot gives is the day it ends and the data goes with it); + * **a storage box that is locked** (critical: its data cannot be reached); **a rescue system left on** for two hours (the server's next boot is into the rescue system, not its own); **a server still + * "in process"** a day after the app first saw it so (an order that was never finished). "Since when" is what this app saw: the time of the first read that showed it. + */ +import { and, eq } from "drizzle-orm"; +import { db } from "../db/client.js"; +import { hetznerRobotState, integrations } from "../db/schema.js"; +import { createHetznerRobotAdapter, type RobotRead, type RobotServer, type RobotStorageBox } from "../integrations/hetznerRobot/adapter.js"; +import { loadIntegrationConfig } from "../integrations/loadIntegration.js"; +import { getInternalFlag, setInternalFlag } from "./settingsStore.js"; + +export const SYNC_INTERVAL_MS = 15 * 60_000; +/** After this long without a good read, what is stored is no longer believed. */ +export const STALE_AFTER_MS = 45 * 60_000; +const STATUS_FLAG = "hetznerRobotSync"; + +const MIN = 60_000; +const HOUR = 60 * MIN; +const DAY = 24 * HOUR; +/** A rescue system on for this long has been forgotten. */ +export const RESCUE_AFTER_MS = 2 * HOUR; +/** A server that has not been "ready" for this long is not being set up any more, it is stuck. */ +export const NOT_READY_AFTER_MS = DAY; +/** A cancelled server or storage box this close to its end is news; this close, urgent. */ +export const ENDING_WARN_DAYS = 30; +export const ENDING_CRITICAL_DAYS = 7; + +export interface RobotSyncStatus { + /** The last read that worked (kept when a later one failed). */ + at: string; + ok: boolean; + error: string | null; +} + +async function readStatuses(): Promise> { + try { + const raw = await getInternalFlag(STATUS_FLAG); + return raw ? (JSON.parse(raw) as Record) : {}; + } catch { + return {}; + } +} + +export async function robotSyncStatuses(): Promise> { + return Object.fromEntries(Object.entries(await readStatuses()).map(([k, v]) => [Number(k), v])); +} + +export const isRobotFresh = (status: RobotSyncStatus | undefined, nowMs: number) => !!status && status.ok && nowMs - Date.parse(status.at) <= STALE_AFTER_MS; + +export type StateRow = typeof hetznerRobotState.$inferSelect; + +function parse(stored: string | null): T | null { + if (stored === null) return null; + try { + return JSON.parse(stored) as T; + } catch { + return null; + } +} + +/** A server as stored: as Robot says it, plus what the app has seen between reads. */ +export interface StoredRobotServer extends RobotServer { + /** When the first read that showed the rescue system on was made; null while it is off (or not known). */ + rescueSince: string | null; + /** When the first read that showed it not "ready" was made; null while it is ready. */ + notReadySince: string | null; +} + +export interface StoredRobot { + servers: StoredRobotServer[]; + storageBoxes: RobotStorageBox[] | null; + skippedDetail: number; + updatedAt: string; +} + +export const storedOf = (row: StateRow): StoredRobot => ({ + servers: (parse(row.servers) ?? []).map((s) => ({ ...s, rescueSince: s.rescueSince ?? null, notReadySince: s.notReadySince ?? null })), + storageBoxes: parse(row.storageBoxes), + skippedDetail: row.skippedDetail, + updatedAt: row.updatedAt, +}); + +/** Pure: the servers as read, with what was seen between reads carried over from the last read by server number. A thing first seen wrong starts its clock now. */ +export function carrySince(servers: RobotServer[], previous: StoredRobotServer[] | null, now: Date): StoredRobotServer[] { + const at = now.toISOString(); + const before = new Map((previous ?? []).map((s) => [s.number, s])); + return servers.map((s) => ({ + ...s, + rescueSince: s.rescue === true ? (before.get(s.number)?.rescueSince ?? at) : null, + notReadySince: s.status !== "ready" ? (before.get(s.number)?.notReadySince ?? at) : null, + })); +} + +/** Writes down one read, replacing the last (and carrying what was seen between reads). */ +export async function storeRead(integrationId: number, r: RobotRead, now: Date = new Date()): Promise { + const [previous] = await db.select().from(hetznerRobotState).where(eq(hetznerRobotState.integrationId, integrationId)).limit(1); + const values = { + servers: JSON.stringify(carrySince(r.servers, previous ? storedOf(previous).servers : null, now)), + storageBoxes: r.storageBoxes && JSON.stringify(r.storageBoxes), + skippedDetail: r.skippedDetail, + updatedAt: now.toISOString(), + }; + await db.insert(hetznerRobotState).values({ integrationId, ...values }).onConflictDoUpdate({ target: hetznerRobotState.integrationId, set: values }); +} + +/** Reads one Robot account and stores it. Never throws: how it went is the answer, and what was stored is left alone when it failed. */ +export async function syncRobot(integrationId: number, now: Date = new Date(), read?: (config: Record) => Promise): Promise { + let status: RobotSyncStatus; + try { + const loaded = await loadIntegrationConfig(integrationId); + if (!loaded || loaded.integration.type !== "hetznerrobot") throw new Error("not a Hetzner Robot integration"); + const result = await (read ? read(loaded.config) : createHetznerRobotAdapter(loaded.config as never).read()); + await storeRead(integrationId, result, now); + status = { at: now.toISOString(), ok: true, error: null }; + } catch (err) { + const previous = (await readStatuses())[String(integrationId)]; + status = { at: previous?.at ?? now.toISOString(), ok: false, error: err instanceof Error ? err.message : String(err) }; + console.error(`[hetzner-robot] couldn't read integration ${integrationId}:`, status.error); + } + try { + const all = await readStatuses(); + all[String(integrationId)] = status; + await setInternalFlag(STATUS_FLAG, JSON.stringify(all)); + } catch (err) { + console.error("[hetzner-robot] couldn't record the result:", err); + } + return status; +} + +export async function syncAllRobot(now: Date = new Date()): Promise> { + const rows = await db.select({ id: integrations.id }).from(integrations).where(and(eq(integrations.type, "hetznerrobot"), eq(integrations.enabled, true))); + const out: Record = {}; + for (const r of rows) out[r.id] = await syncRobot(r.id, now); + return out; +} + +export async function forgetRobot(integrationId: number): Promise { + const all = await readStatuses(); + if (String(integrationId) in all) { + delete all[String(integrationId)]; + await setInternalFlag(STATUS_FLAG, JSON.stringify(all)); + } +} + +// ─── What is wrong ────────────────────────────────────────────────────────── + +export interface RobotProblem { + key: string; + message: string; + severity: "warning" | "critical"; +} + +const plural = (n: number, unit: string) => `${n} ${unit}${n === 1 ? "" : "s"}`; +const ago = (ms: number): string => (ms >= 48 * HOUR ? plural(Math.round(ms / DAY), "day") : ms >= HOUR ? plural(Math.round(ms / HOUR), "hour") : plural(Math.max(1, Math.round(ms / MIN)), "minute")); + +/** Pure: how many calendar days (UTC) there are from today to a date "YYYY-MM-DD": 0 on the day itself, which it still runs through, and negative once it has passed. */ +export function daysLeft(date: string | null, nowMs: number): number | null { + if (date === null) return null; + const end = Date.parse(date); + if (!Number.isFinite(end)) return null; + const now = new Date(nowMs); + return Math.round((end - Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())) / DAY); +} + +const endsIn = (days: number) => (days < 0 ? "has ended" : days === 0 ? "ends today" : days === 1 ? "ends tomorrow" : `ends in ${days} days`); + +/** Pure: what is wrong with one Robot account, from what is stored for it. */ +export function robotProblems(id: number, name: string, s: StoredRobot, nowMs: number): RobotProblem[] { + const out: RobotProblem[] = []; + for (const v of s.servers) { + const label = `${v.name} (server ${v.number})`; + if (v.cancelled) { + const left = daysLeft(v.paidUntil, nowMs); + if (left !== null && left <= ENDING_WARN_DAYS) { + out.push({ key: `hetznerrobot-ending:${id}:${v.number}`, severity: left <= ENDING_CRITICAL_DAYS ? "critical" : "warning", message: `${name}: ${label} is cancelled and ${endsIn(left)} (${v.paidUntil}) — the server and its data go with it` }); + } + } + if (v.rescue === true && v.rescueSince !== null && nowMs - Date.parse(v.rescueSince) >= RESCUE_AFTER_MS) { + out.push({ key: `hetznerrobot-rescue:${id}:${v.number}`, severity: "warning", message: `${name}: the rescue system of ${label} has been switched on for ${ago(nowMs - Date.parse(v.rescueSince))} — its next boot is into the rescue system, not its own` }); + } + if (v.status !== "ready" && v.notReadySince !== null && nowMs - Date.parse(v.notReadySince) >= NOT_READY_AFTER_MS) { + out.push({ key: `hetznerrobot-setup:${id}:${v.number}`, severity: "warning", message: `${name}: ${label} has been “${v.status}” for ${ago(nowMs - Date.parse(v.notReadySince))} instead of ready` }); + } + } + for (const b of s.storageBoxes ?? []) { + const label = `storage box ${b.name}${b.login ? ` (${b.login})` : ""}`; + if (b.locked) out.push({ key: `hetznerrobot-boxlocked:${id}:${b.id}`, severity: "critical", message: `${name}: ${label} is locked — its data cannot be reached` }); + if (b.cancelled) { + const left = daysLeft(b.paidUntil, nowMs); + if (left !== null && left <= ENDING_WARN_DAYS) { + out.push({ key: `hetznerrobot-boxending:${id}:${b.id}`, severity: left <= ENDING_CRITICAL_DAYS ? "critical" : "warning", message: `${name}: ${label} is cancelled and ${endsIn(left)} (${b.paidUntil}) — its data goes with it` }); + } + } + } + return out; +} + +let timer: ReturnType | null = null; + +export function initHetznerRobotSync(): void { + if (timer) return; + const pass = () => void syncAllRobot().catch((err) => console.error("[hetzner-robot] pass failed:", err)); + timer = setInterval(pass, SYNC_INTERVAL_MS); + setTimeout(pass, 47_000); + console.log(`[hetzner-robot] reading Hetzner Robot every ${SYNC_INTERVAL_MS / 60000} minutes`); +} diff --git a/server/src/services/integrationGroups.ts b/server/src/services/integrationGroups.ts index fb33569..5b7d2e2 100644 --- a/server/src/services/integrationGroups.ts +++ b/server/src/services/integrationGroups.ts @@ -3,7 +3,7 @@ * and not the other is caught. A kind in no group (an older one) is simply not in any group's summary. */ export const INTEGRATION_GROUPS: { id: string; label: string; types: string[] }[] = [ - { id: "infrastructure", label: "Infrastructure", types: ["proxmox", "synology", "dockhand", "hetzner", "fragnet", "tailscale"] }, + { id: "infrastructure", label: "Infrastructure", types: ["proxmox", "synology", "dockhand", "hetzner", "hetznerrobot", "fragnet", "tailscale"] }, { id: "apps", label: "Apps", types: ["homeassistant", "jellyfin", "sonarr", "radarr", "lidarr", "readarr", "prowlarr", "qbittorrent", "sabnzbd", "immich", "paperless", "nextcloud", "authentik"] }, { id: "backups", label: "Backups", types: ["pbs"] }, { id: "network", label: "Network", types: ["unifi", "npm", "phpipam", "netbox", "adguard", "technitium"] }, diff --git a/server/src/services/maintenance.ts b/server/src/services/maintenance.ts index 0e70995..12329f3 100644 --- a/server/src/services/maintenance.ts +++ b/server/src/services/maintenance.ts @@ -45,6 +45,8 @@ export function subjectOfConditionKey(key: string): string | null { if (m) return `integration:${m[1]}`; m = /^(?:sonarr|radarr|prowlarr|lidarr|readarr)-(?:health|queue|disk):(\d+)/.exec(key); if (m) return `integration:${m[1]}`; + m = /^hetznerrobot-(?:ending|rescue|setup|boxlocked|boxending):(\d+):/.exec(key); + if (m) return `integration:${m[1]}`; m = /^(?:qbittorrent|sabnzbd)-(?:stuck|connection|paused|stalled|disk):(\d+)/.exec(key); if (m) return `integration:${m[1]}`; m = /^version-behind:(\d+)$/.exec(key); diff --git a/server/src/services/metrics.ts b/server/src/services/metrics.ts index 2663653..9bd62c3 100644 --- a/server/src/services/metrics.ts +++ b/server/src/services/metrics.ts @@ -5,7 +5,7 @@ */ import { eq, inArray } from "drizzle-orm"; import { db } from "../db/client.js"; -import { downloadState, technitiumState, assets, endpointChecks, heartbeats, integrations, maintenanceWindows, secrets, servers, upsState, jellyfinState, authentikState, immichState, paperlessState, nextcloudState, netboxState, n8nState, dockhandVulnerabilities, hetznerState, fragnetState, arrState, adguardState, grafanaState } from "../db/schema.js"; +import { hetznerRobotState, downloadState, technitiumState, assets, endpointChecks, heartbeats, integrations, maintenanceWindows, secrets, servers, upsState, jellyfinState, authentikState, immichState, paperlessState, nextcloudState, netboxState, n8nState, dockhandVulnerabilities, hetznerState, fragnetState, arrState, adguardState, grafanaState } from "../db/schema.js"; import { isUpsFresh, upsSyncStatuses } from "./upsSync.js"; import { levelStatuses } from "./serviceLevels.js"; import { backupState, listAll as listDuplicati } from "./duplicati.js"; @@ -15,6 +15,7 @@ import { dockerVulnSyncStatuses, isDockerVulnFresh } from "./dockerVulnSync.js"; import { isSpeedtestFresh, recentResults as recentSpeedtestResults, speedtestSyncStatuses } from "./speedtestSync.js"; import { costOf as hetznerCostOf, hetznerSyncStatuses, isHetznerFresh, serversOf as hetznerServersOf, loadBalancersOf as hetznerLoadBalancersOf, certificatesOf as hetznerCertificatesOf, trafficForecast as hetznerTrafficForecast } from "./hetznerSync.js"; import { ARR_KINDS } from "../integrations/arr/adapter.js"; +import { daysLeft as robotDaysLeft, isRobotFresh, robotSyncStatuses, storedOf as robotStoredOf } from "./hetznerRobotSync.js"; import { DOWNLOAD_KINDS, DOWNLOAD_STATES } from "../integrations/downloads/adapter.js"; import { downloadSyncStatuses, isDownloadFresh, recentFailed as downloadsFailed, storedOf as downloadStoredOf, stuckItems as downloadStuck } from "./downloadsSync.js"; import { versionRows as appVersionRows } from "./appVersions.js"; @@ -212,6 +213,34 @@ async function addArrMetrics(out: Exposition, now: Date) { } } +/** Each Hetzner Robot account, for /metrics: for each dedicated server whether its rescue system is on and, if it is cancelled, the days left; for each storage box whether it is locked and, if cancelled, the days left. Only while the reading is recent. */ +async function addRobotMetrics(out: Exposition, now: Date) { + const statuses = await robotSyncStatuses(); + const rows = new Map((await db.select({ id: integrations.id, name: integrations.name, enabled: integrations.enabled }).from(integrations).where(eq(integrations.type, "hetznerrobot"))).map((r) => [r.id, r])); + for (const s of await db.select().from(hetznerRobotState)) { + const row = rows.get(s.integrationId); + if (!row || !row.enabled || !isRobotFresh(statuses[s.integrationId], now.getTime())) continue; + const state = robotStoredOf(s); + out.add("homelab_hetzner_robot_servers", "gauge", "How many dedicated servers the Hetzner Robot account has.", state.servers.length, { name: row.name }); + for (const v of state.servers) { + const labels = { name: row.name, server: String(v.number), server_name: v.name }; + if (v.rescue !== null) out.add("homelab_hetzner_robot_rescue_active", "gauge", "1 if a dedicated server's rescue system is switched on for the next boot, else 0.", v.rescue ? 1 : 0, labels); + if (v.cancelled) { + const left = robotDaysLeft(v.paidUntil, now.getTime()); + if (left !== null) out.add("homelab_hetzner_robot_days_left", "gauge", "Calendar days left of a cancelled dedicated server or storage box: 0 on the day it ends, negative after.", left, labels); + } + } + for (const b of state.storageBoxes ?? []) { + const labels = { name: row.name, storage_box: String(b.id), storage_box_name: b.name }; + out.add("homelab_hetzner_robot_storage_box_locked", "gauge", "1 if a storage box is locked, else 0.", b.locked ? 1 : 0, labels); + if (b.cancelled) { + const left = robotDaysLeft(b.paidUntil, now.getTime()); + if (left !== null) out.add("homelab_hetzner_robot_days_left", "gauge", "Calendar days left of a cancelled dedicated server or storage box: 0 on the day it ends, negative after.", left, labels); + } + } + } +} + /** Each qBittorrent and SABnzbd, for /metrics: how fast it is going, the items in each state and how many are stuck, whether it is connected or paused, what failed in the last day and the free space of its disk. Only while the reading is recent. */ async function addDownloadMetrics(out: Exposition, now: Date) { const statuses = await downloadSyncStatuses(); @@ -609,6 +638,7 @@ export async function buildMetrics(now: Date = new Date()): Promise { await addFragnetMetrics(out, now); await addArrMetrics(out, now); await addDownloadMetrics(out, now); + await addRobotMetrics(out, now); await addAdguardMetrics(out, now); await addTechnitiumMetrics(out, now); await addVersionMetrics(out); diff --git a/server/test/hetznerRobot.test.ts b/server/test/hetznerRobot.test.ts new file mode 100644 index 0000000..abc5d70 --- /dev/null +++ b/server/test/hetznerRobot.test.ts @@ -0,0 +1,394 @@ +/** + * Hetzner Robot: reading what its webservice says (dedicated servers, storage boxes, whether a rescue system is on), what is stored, what is wrong (about to shut down, locked, a rescue system left on, + * stuck being set up), the health pass, the alerts, the page's data and /metrics. + * + * Run with: npm test --workspace server + */ +import { test, describe, before, after } from "node:test"; +import assert from "node:assert/strict"; +import { createServer as createHttpServer, type Server } from "node:http"; +import { mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import type { AddressInfo } from "node:net"; + +const dir = mkdtempSync(join(tmpdir(), "hm-robot-")); +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, integrations, hetznerRobotState } = await import("../src/db/schema.js"); +const { runMigrations } = await import("../src/db/migrate.js"); +const adapter = await import("../src/integrations/hetznerRobot/adapter.js"); +const robot = await import("../src/services/hetznerRobotSync.js"); +const { evaluateHealth, collectSnapshot } = await import("../src/services/healthMonitor.js"); +const { subjectOfConditionKey } = await import("../src/services/maintenance.js"); +const { getAlerts, invalidateAlertsCache } = await import("../src/services/alerts.js"); +const { hetznerRobotRouter } = await import("../src/routes/hetznerRobot.js"); +const { buildMetrics } = await import("../src/services/metrics.js"); +const { setInternalFlag } = await import("../src/services/settingsStore.js"); +const { INTEGRATION_FIELDS, validateIntegrationConfig, resolveBaseUrl } = await import("../src/integrations/fieldSchemas.js"); +const { createIntegrationAdapter } = await import("../src/integrations/registry.js"); +const { eq } = await import("drizzle-orm"); + +await runMigrations(); + +const MIN = 60_000; +const HOUR = 60 * MIN; +const DAY = 24 * HOUR; +const iso = (ms: number) => new Date(ms).toISOString(); +/** A date "YYYY-MM-DD" this many days from `base`. */ +const dateIn = (days: number, base = Date.now()) => iso(base + days * DAY).slice(0, 10); + +type Server_ = import("../src/integrations/hetznerRobot/adapter.js").RobotServer; +type Box = import("../src/integrations/hetznerRobot/adapter.js").RobotStorageBox; +type Read = import("../src/integrations/hetznerRobot/adapter.js").RobotRead; + +const server = (extra: Partial = {}): Server_ => ({ number: 100, name: "metal-1", ip: "203.0.113.5", ipv6: "2001:db8::", product: "AX41-NVMe", dc: "FSN1-DC14", traffic: "unlimited", status: "ready", cancelled: false, paidUntil: null, rescue: false, ...extra }); +const box = (extra: Partial = {}): Box => ({ id: 7, name: "backups", login: "u123456", product: "BX20", location: "FSN1", cancelled: false, locked: false, paidUntil: null, linkedServer: null, ...extra }); +const read = (extra: Partial = {}): Read => ({ servers: [server()], storageBoxes: [box()], skippedDetail: 0, ...extra }); + +// What Robot sends: each entry wrapped in an object of its own kind. +const apiServer = (n: number, extra: Record = {}) => ({ server: { server_ip: `203.0.113.${n}`, server_ipv6_net: "2001:db8::", server_number: n, server_name: `metal-${n}`, product: "AX41-NVMe", dc: "FSN1-DC14", traffic: "unlimited", status: "ready", cancelled: false, paid_until: "2027-01-01", ...extra } }); + +describe("what Robot says", () => { + test("a server: number, name, product, data centre, addresses, traffic plan, status, cancelled and until when — wrapped or not", () => { + const s = adapter.parseServer(apiServer(5, { cancelled: true, paid_until: "2026-12-01", status: "In Process" }))!; + assert.deepEqual([s.number, s.name, s.ip, s.ipv6, s.product, s.dc, s.traffic, s.status, s.cancelled, s.paidUntil, s.rescue], [5, "metal-5", "203.0.113.5", "2001:db8::", "AX41-NVMe", "FSN1-DC14", "unlimited", "in process", true, "2026-12-01", null]); + assert.equal(adapter.parseServer(apiServer(5).server)!.number, 5, "a bare object too"); + assert.equal(adapter.parseServer({ server: { server_number: 9, rescue: true } })!.rescue, true); + assert.equal(adapter.parseServer({ server: { server_number: 9, server_name: "", product: "EX44" } })!.name, "EX44"); + assert.equal(adapter.parseServer({ server: { server_number: 9 } })!.name, "Server 9"); + assert.equal(adapter.parseServer({ server: { server_name: "no number" } }), null); + assert.equal(adapter.parseServer({ server: { server_number: 1, paid_until: "soon" } })!.paidUntil, null); + assert.equal(adapter.parseServer({ server: { server_number: 1, paid_until: "2026-12-01 10:00:00" } })!.paidUntil, "2026-12-01"); + }); + + test("a storage box: id, name, login, product, location, cancelled, locked, paid until, the server it is linked to", () => { + const b = adapter.parseStorageBox({ storagebox: { id: 3, login: "u1", name: "Photos", product: "BX40", location: "HEL1", cancelled: true, locked: true, paid_until: "2026-11-30", linked_server: 100 } })!; + assert.deepEqual([b.id, b.name, b.login, b.product, b.location, b.cancelled, b.locked, b.paidUntil, b.linkedServer], [3, "Photos", "u1", "BX40", "HEL1", true, true, "2026-11-30", 100]); + assert.equal(adapter.parseStorageBox({ storagebox: { id: 4, login: "u2" } })!.name, "u2"); + assert.equal(adapter.parseStorageBox({ storagebox: { login: "no id" } }), null); + }); + + describe("the adapter against a Robot that answers", () => { + let fake: Server; + let url = ""; + let servers = [apiServer(2), apiServer(1)]; + let listStatus = 200; + let boxStatus = 200; + let detailFails = new Set(); + const seen: { method: string | undefined; path: string; auth: string | undefined }[] = []; + before(async () => { + fake = createHttpServer((req, res) => { + const u = new URL(req.url ?? "", "http://x"); + seen.push({ method: req.method, path: u.pathname, auth: req.headers.authorization }); + const send = (code: number, body: unknown) => { + res.writeHead(code, { "content-type": "application/json" }); + res.end(JSON.stringify(body)); + }; + const fail = (code: number, c: string) => send(code, { error: { status: code, code: c, message: c } }); + if (req.headers.authorization !== `Basic ${Buffer.from("#ws+abc:p@ss:word").toString("base64")}`) return fail(401, "UNAUTHORIZED"); + if (u.pathname === "/server") return listStatus === 200 ? (servers.length === 0 ? fail(404, "SERVER_NOT_FOUND") : send(200, servers)) : fail(listStatus, "RATE_LIMIT_EXCEEDED"); + const one = /^\/server\/(\d+)$/.exec(u.pathname); + if (one) return detailFails.has(Number(one[1])) ? fail(500, "INTERNAL_ERROR") : send(200, apiServer(Number(one[1]), { rescue: one[1] === "2" })); + if (u.pathname === "/storagebox") return boxStatus === 200 ? send(200, [{ storagebox: { id: 7, login: "u1", name: "backups", cancelled: false, locked: false } }]) : boxStatus === 404 ? fail(404, "STORAGEBOX_NOT_FOUND") : fail(boxStatus, "INTERNAL_ERROR"); + fail(404, "NOT_FOUND"); + }); + await new Promise((resolve) => fake.listen(0, "127.0.0.1", resolve)); + url = `http://127.0.0.1:${(fake.address() as AddressInfo).port}`; + }); + after(() => fake.close()); + const make = (extra: Record = {}) => adapter.createHetznerRobotAdapter({ user: "#ws+abc", password: "p@ss:word", apiUrl: url, ...extra }); + + test("the servers by number, each asked about for its rescue system, and the storage boxes — with the webservice user as Basic auth, and only ever GET", async () => { + seen.length = 0; + const r = await make().read(); + assert.deepEqual(r.servers.map((s) => [s.number, s.rescue]), [[1, false], [2, true]]); + assert.deepEqual([r.storageBoxes?.map((b) => b.name), r.skippedDetail], [["backups"], 0]); + assert.ok(seen.every((s) => s.method === "GET")); + assert.deepEqual(seen.map((s) => s.path).sort(), ["/server", "/server/1", "/server/2", "/storagebox"]); + }); + + test("an account with nothing in it is answered with a 404 and a code ending in NOT_FOUND, which is none — not a failure", async () => { + servers = []; + boxStatus = 404; + const r = await make().read(); + assert.deepEqual([r.servers, r.storageBoxes], [[], []]); + assert.equal((await make().ping()).ok, true); + servers = [apiServer(2), apiServer(1)]; + boxStatus = 200; + }); + + test("a part that cannot be read is null (the storage boxes) or unknown (a server's rescue system), not empty or off; the list of servers is what must work", async () => { + boxStatus = 500; + detailFails = new Set([2]); + const r = await make().read(); + assert.deepEqual([r.storageBoxes, r.servers.map((s) => s.rescue)], [null, [false, null]]); + boxStatus = 200; + detailFails = new Set(); + listStatus = 403; + await assert.rejects(() => make().read(), /refused the request \(HTTP 403, RATE_LIMIT_EXCEEDED\).*200 requests/); + listStatus = 200; + }); + + test("only the first 25 servers are asked about, to stay under Robot's 200 requests an hour; the rest are counted", async () => { + servers = Array.from({ length: 27 }, (_, i) => apiServer(i + 1)); + seen.length = 0; + const r = await make().read(); + assert.deepEqual([r.servers.length, r.skippedDetail, seen.filter((s) => /^\/server\/\d+$/.test(s.path)).length], [27, 2, 25]); + assert.deepEqual([r.servers[24].rescue, r.servers[25].rescue], [false, null]); + servers = [apiServer(2), apiServer(1)]; + }); + + test("a wrong password and an address that is not Robot are said", async () => { + const bad = await make({ password: "nope" }).ping(); + assert.equal(bad.ok, false); + assert.match(bad.error ?? "", /did not accept the user name and password \(HTTP 401\).*webservice user/); + assert.equal((await make().ping()).ok, true); + assert.equal((await adapter.createHetznerRobotAdapter({ user: "a", password: "b", apiUrl: "http://127.0.0.1:1" }).ping()).ok, false); + }); + }); +}); + +describe("what is wrong", () => { + const NOW = Date.parse("2026-06-10T12:00:00Z"); + const stored = (extra: Partial = {}): import("../src/services/hetznerRobotSync.js").StoredRobot => ({ + servers: robot.carrySince([server()], null, new Date(NOW)), + storageBoxes: [box()], + skippedDetail: 0, + updatedAt: iso(NOW), + ...extra, + }); + const withServer = (extra: Partial) => stored({ servers: [{ ...robot.carrySince([server()], null, new Date(NOW))[0], ...extra }] }); + const keys = (list: ReturnType) => list.map((p) => `${p.key}=${p.severity}`); + + test("an account that is well says nothing", () => { + assert.deepEqual(robot.robotProblems(1, "Hetzner", stored(), NOW), []); + assert.deepEqual(robot.robotProblems(1, "Hetzner", stored({ storageBoxes: null }), NOW), []); + }); + + test("days left are calendar days to the date: 0 on the day itself, negative once it has passed", () => { + assert.equal(robot.daysLeft("2026-06-10", NOW), 0, "ends today"); + assert.equal(robot.daysLeft("2026-06-09", NOW), -1); + assert.equal(robot.daysLeft("2026-06-10", Date.parse("2026-06-10T23:30:00Z")), 0, "late in the day it is still today"); + assert.equal(robot.daysLeft("2026-07-10", NOW), 30); + assert.deepEqual([robot.daysLeft(null, NOW), robot.daysLeft("nonsense", NOW)], [null, null]); + }); + + describe("a cancelled server", () => { + const cancelled = (days: number) => withServer({ cancelled: true, paidUntil: dateIn(days, NOW) }); + test("within 30 days is a warning, within 7 critical; further off, or not cancelled, is nothing", () => { + assert.deepEqual(robot.robotProblems(1, "H", cancelled(45), NOW), []); + assert.deepEqual(keys(robot.robotProblems(1, "H", cancelled(30), NOW)), ["hetznerrobot-ending:1:100=warning"]); + assert.deepEqual(keys(robot.robotProblems(1, "H", cancelled(10), NOW)), ["hetznerrobot-ending:1:100=warning"]); + assert.deepEqual(keys(robot.robotProblems(1, "H", cancelled(6), NOW)), ["hetznerrobot-ending:1:100=critical"]); + assert.deepEqual(robot.robotProblems(1, "H", withServer({ cancelled: false, paidUntil: dateIn(2, NOW) }), NOW), [], "paid until soon is only a renewal"); + assert.deepEqual(robot.robotProblems(1, "H", withServer({ cancelled: true, paidUntil: null }), NOW), [], "no date, no days"); + }); + test("the message names the server, says when and warns that the data goes", () => { + const m = robot.robotProblems(1, "Hetzner", cancelled(10), NOW)[0].message; + assert.match(m, /^Hetzner: metal-1 \(server 100\) is cancelled and ends in 10 days \(\d{4}-\d{2}-\d{2}\) — the server and its data go with it$/); + assert.match(robot.robotProblems(1, "H", cancelled(0), NOW)[0].message, /is cancelled and ends today \(/); + assert.match(robot.robotProblems(1, "H", cancelled(1), NOW)[0].message, /is cancelled and ends tomorrow \(/); + assert.match(robot.robotProblems(1, "H", withServer({ cancelled: true, paidUntil: "2026-06-01" }), NOW)[0].message, /has ended/); + }); + }); + + describe("a rescue system left on, and a server stuck being set up", () => { + test("rescue on for two hours is raised; for less is not; off or unknown never is", () => { + const on = (ago: number) => withServer({ rescue: true, rescueSince: iso(NOW - ago) }); + const p = robot.robotProblems(1, "H", on(5 * HOUR), NOW); + assert.deepEqual(keys(p), ["hetznerrobot-rescue:1:100=warning"]); + assert.equal(p[0].message, "H: the rescue system of metal-1 (server 100) has been switched on for 5 hours — its next boot is into the rescue system, not its own"); + assert.deepEqual(robot.robotProblems(1, "H", on(30 * MIN), NOW), []); + assert.deepEqual(robot.robotProblems(1, "H", withServer({ rescue: null, rescueSince: iso(NOW - DAY) }), NOW), []); + assert.deepEqual(robot.robotProblems(1, "H", withServer({ rescue: false, rescueSince: null }), NOW), []); + }); + test("not ready for a day is raised, and says what it is", () => { + const p = robot.robotProblems(1, "H", withServer({ status: "in process", notReadySince: iso(NOW - 3 * DAY) }), NOW); + assert.deepEqual(keys(p), ["hetznerrobot-setup:1:100=warning"]); + assert.equal(p[0].message, "H: metal-1 (server 100) has been “in process” for 3 days instead of ready"); + assert.deepEqual(robot.robotProblems(1, "H", withServer({ status: "in process", notReadySince: iso(NOW - 2 * HOUR) }), NOW), []); + }); + test("what is seen between reads: the clock starts at the first read that shows it, is kept while it goes on, and is dropped when it is over", () => { + const t0 = new Date(NOW); + const t1 = new Date(NOW + 20 * MIN); + const first = robot.carrySince([server({ number: 1, rescue: true }), server({ number: 2, status: "in process" })], null, t0); + assert.deepEqual(first.map((s) => [s.rescueSince, s.notReadySince]), [[t0.toISOString(), null], [null, t0.toISOString()]]); + const second = robot.carrySince([server({ number: 1, rescue: true }), server({ number: 2, status: "ready" }), server({ number: 3, rescue: true })], first, t1); + assert.deepEqual(second.map((s) => [s.rescueSince, s.notReadySince]), [[t0.toISOString(), null], [null, null], [t1.toISOString(), null]]); + }); + }); + + describe("storage boxes", () => { + test("a locked one is critical; one cancelled within 30 days is a warning, within 7 critical", () => { + assert.deepEqual(keys(robot.robotProblems(1, "H", stored({ storageBoxes: [box({ locked: true })] }), NOW)), ["hetznerrobot-boxlocked:1:7=critical"]); + assert.deepEqual(keys(robot.robotProblems(1, "H", stored({ storageBoxes: [box({ cancelled: true, paidUntil: dateIn(20, NOW) })] }), NOW)), ["hetznerrobot-boxending:1:7=warning"]); + assert.deepEqual(keys(robot.robotProblems(1, "H", stored({ storageBoxes: [box({ cancelled: true, paidUntil: dateIn(3, NOW) })] }), NOW)), ["hetznerrobot-boxending:1:7=critical"]); + assert.deepEqual(robot.robotProblems(1, "H", stored({ storageBoxes: [box({ cancelled: true, paidUntil: dateIn(90, NOW) })] }), NOW), []); + assert.match(robot.robotProblems(1, "H", stored({ storageBoxes: [box({ locked: true })] }), NOW)[0].message, /^H: storage box backups \(u123456\) is locked — its data cannot be reached$/); + }); + }); +}); + +describe("what is stored", () => { + let id = 0; + before(async () => { + id = (await db.insert(integrations).values({ type: "hetznerrobot", name: "Metal", baseUrl: "https://robot-ws.your-server.de", config: JSON.stringify({}) }).returning({ id: integrations.id }))[0].id; + }); + const row = async () => (await db.select().from(hetznerRobotState).where(eq(hetznerRobotState.integrationId, id)))[0]; + after(async () => { + await robot.forgetRobot(id); + await db.delete(integrations).where(eq(integrations.id, id)); + }); + + test("the state is replaced at each read; storage boxes that could not be read are stored as null", async () => { + await robot.storeRead(id, read({ storageBoxes: null, skippedDetail: 3 }), new Date()); + let s = robot.storedOf(await row()); + assert.deepEqual([s.storageBoxes, s.servers.length, s.skippedDetail], [null, 1, 3]); + await robot.storeRead(id, read({ servers: [server(), server({ number: 101, name: "metal-2" })] }), new Date()); + s = robot.storedOf(await row()); + assert.deepEqual([s.servers.map((x) => x.name), s.storageBoxes?.length], [["metal-1", "metal-2"], 1]); + }); + + test("since when the rescue system has been on is carried from read to read, and dropped when it is off", async () => { + const t0 = new Date(Date.now() - 5 * HOUR); + await robot.storeRead(id, read({ servers: [server({ rescue: true })] }), t0); + await robot.storeRead(id, read({ servers: [server({ rescue: true })] }), new Date()); + assert.equal(robot.storedOf(await row()).servers[0].rescueSince, t0.toISOString()); + await robot.storeRead(id, read(), new Date()); + assert.equal(robot.storedOf(await row()).servers[0].rescueSince, null); + }); + + test("a read that failed is said, and what was stored is left alone", async () => { + const ok = await robot.syncRobot(id, new Date(), async () => read({ servers: [server({ name: "kept" })] })); + assert.equal(ok.ok, true); + const failed = await robot.syncRobot(id, new Date(), async () => { + throw new Error("connection refused"); + }); + assert.deepEqual([failed.ok, failed.error], [false, "connection refused"]); + assert.equal(failed.at, ok.at); + assert.equal(robot.storedOf(await row()).servers[0].name, "kept"); + assert.equal(robot.isRobotFresh((await robot.robotSyncStatuses())[id], Date.now()), false); + }); + + test("an integration of another type is not read as Robot", async () => { + const other = (await db.insert(integrations).values({ type: "gitea", name: "G", baseUrl: "http://g", config: JSON.stringify({}) }).returning({ id: integrations.id }))[0].id; + const status = await robot.syncRobot(other, new Date(), async () => read()); + assert.deepEqual([status.ok, status.error], [false, "not a Hetzner Robot integration"]); + await robot.forgetRobot(other); + await db.delete(integrations).where(eq(integrations.id, other)); + }); +}); + +describe("adding one", () => { + test("it needs a webservice user and its password (kept secret), and no address — Robot has one", () => { + assert.deepEqual(validateIntegrationConfig("hetznerrobot", { user: "#ws+x", password: "p" }), []); + assert.deepEqual(validateIntegrationConfig("hetznerrobot", {}), ["user", "password"]); + assert.equal(INTEGRATION_FIELDS.hetznerrobot!.find((f) => f.key === "password")!.secret, true); + assert.equal(resolveBaseUrl("hetznerrobot", {}), "https://robot-ws.your-server.de"); + const a = createIntegrationAdapter("hetznerrobot", { user: "u", password: "p" } as never) as unknown as Record; + assert.deepEqual([typeof a.ping, typeof a.read], ["function", "function"]); + }); +}); + +describe("the health pass, the page and /metrics", () => { + let aId = 0; + let app: Server; + let base = ""; + const fresh = () => setInternalFlag("hetznerRobotSync", JSON.stringify({ [aId]: { at: new Date().toISOString(), ok: true, error: null } })); + const stale = () => setInternalFlag("hetznerRobotSync", JSON.stringify({ [aId]: { at: new Date(Date.now() - 60 * MIN).toISOString(), ok: true, error: null } })); + + before(async () => { + await db.insert(users).values([{ oidcSub: "viewer", name: "Vic", role: "viewer" }]); + aId = (await db.insert(integrations).values({ type: "hetznerrobot", name: "Metal", baseUrl: "https://robot-ws.your-server.de", config: JSON.stringify({}) }).returning({ id: integrations.id }))[0].id; + const now = Date.now(); + // One server cancelled and ending in four days, one with the rescue system on for five hours, one fine; a locked storage box and one cancelled further off. + const servers = [server({ number: 100, name: "metal-1", cancelled: true, paidUntil: dateIn(4, now) }), server({ number: 101, name: "metal-2", rescue: true }), server({ number: 102, name: "metal-3" })]; + const boxes = [box({ id: 7, locked: true }), box({ id: 8, name: "old", cancelled: true, paidUntil: dateIn(90, now) })]; + await robot.storeRead(aId, read({ servers, storageBoxes: boxes }), new Date(now - 5 * HOUR)); + await robot.storeRead(aId, read({ servers, storageBoxes: boxes }), new Date(now)); + await fresh(); + const a = express(); + a.use((req, _res, next) => { + (req as unknown as { session: unknown }).session = { user: { sub: "viewer" } }; + next(); + }); + a.use("/api/hetzner-robot", hetznerRobotRouter); + 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/hetzner-robot`; + }); + after(() => { + app.close(); + try { + rmSync(dir, { recursive: true, force: true }); + } catch { + // Windows keeps the database file locked until the process exits. + } + }); + + test("the health pass judges the account from what is stored, and holds it when the last read is old", async () => { + let { snapshot, held } = await collectSnapshot(); + assert.deepEqual(snapshot.hetznerRobot?.map((r) => r.integrationId), [aId]); + const list = evaluateHealth(snapshot, { serverOfflineMinutes: 60, diskUsagePercent: 90 }, Date.now(), { skipServers: true }); + const mine = list.filter((x) => x.key.startsWith("hetznerrobot-")); + assert.deepEqual(mine.map((x) => x.key).sort(), [`hetznerrobot-ending:${aId}:100`, `hetznerrobot-rescue:${aId}:101`, `hetznerrobot-boxlocked:${aId}:7`].sort()); + const ending = mine.find((x) => x.key === `hetznerrobot-ending:${aId}:100`)!; + assert.deepEqual([ending.severity, ending.source], ["critical", `hetznerrobot:${aId}`]); + for (const k of ["ending", "rescue", "setup", "boxlocked", "boxending"]) assert.equal(subjectOfConditionKey(`hetznerrobot-${k}:${aId}:1`), `integration:${aId}`); + await stale(); + ({ snapshot, held } = await collectSnapshot()); + assert.deepEqual([snapshot.hetznerRobot, held.has(`hetznerrobot:${aId}`)], [undefined, true]); + await fresh(); + }); + + test("the Alerts page puts them under Services, names the source, and links to the Hetzner Robot page", async () => { + invalidateAlertsCache(); + const report = await getAlerts(true); + const a = report.alerts.find((x) => x.id.endsWith(`hetznerrobot-ending:${aId}:100`))!; + const locked = report.alerts.find((x) => x.id.endsWith(`hetznerrobot-boxlocked:${aId}:7`))!; + assert.deepEqual([a.category, a.source, a.link, a.target?.type, locked.category, locked.severity], ["services", "Hetzner Robot", "/hetzner-robot", "integration", "services", "critical"]); + }); + + test("the page: the account with its servers (rescue, cancellation with days left), storage boxes and what is wrong", async () => { + type Body = { accounts: { id: number; fresh: boolean; problems: { key: string }[]; state: { servers: { number: number; rescue: boolean | null; rescueSince: string | null }[]; storageBoxes: { id: number; locked: boolean }[] | null; serverDays: Record; boxDays: Record } }[] }; + const body = (await (await fetch(base)).json()) as Body; + const a = body.accounts.find((x) => x.id === aId)!; + assert.deepEqual([a.fresh, a.state.servers.map((s) => s.number), a.problems.length, Object.keys(a.state.serverDays), a.state.storageBoxes?.map((b) => [b.id, b.locked])], [true, [100, 101, 102], 3, ["100"], [[7, true], [8, false]]]); + assert.ok(a.state.serverDays["100"]! >= 3 && a.state.serverDays["100"]! <= 5); + assert.deepEqual(Object.keys(a.state.boxDays), ["8"]); + assert.ok(a.state.servers.find((s) => s.number === 101)!.rescueSince); + await stale(); + const old = (await (await fetch(base)).json()) as Body; + assert.deepEqual(old.accounts.find((x) => x.id === aId)!.problems, [], "an old reading says nothing is wrong"); + await fresh(); + }); + + test("/metrics has the servers, the rescue systems, the days left and the locked boxes — only while the reading is recent", async () => { + let text = await buildMetrics(new Date()); + assert.match(text, /homelab_hetzner_robot_servers\{name="Metal"\} 3/); + assert.match(text, /homelab_hetzner_robot_rescue_active\{name="Metal",server="101",server_name="metal-2"\} 1/); + assert.match(text, /homelab_hetzner_robot_rescue_active\{name="Metal",server="100",server_name="metal-1"\} 0/); + assert.match(text, /homelab_hetzner_robot_days_left\{name="Metal",server="100",server_name="metal-1"\} [345]/); + assert.doesNotMatch(text, /homelab_hetzner_robot_days_left\{name="Metal",server="102"/, "not cancelled, no days"); + assert.match(text, /homelab_hetzner_robot_storage_box_locked\{name="Metal",storage_box="7",storage_box_name="backups"\} 1/); + assert.match(text, /homelab_hetzner_robot_days_left\{name="Metal",storage_box="8",storage_box_name="old"\} (89|90|91)/); + await stale(); + text = await buildMetrics(new Date()); + assert.doesNotMatch(text, /homelab_hetzner_robot_/); + await fresh(); + }); + + test("taking the integration away takes what was read with it", async () => { + await robot.forgetRobot(aId); + assert.equal((await robot.robotSyncStatuses())[aId], undefined); + await db.delete(integrations).where(eq(integrations.id, aId)); + assert.deepEqual(await db.select().from(hetznerRobotState).where(eq(hetznerRobotState.integrationId, aId)), []); + }); +}); diff --git a/web/src/App.tsx b/web/src/App.tsx index f0fd159..97d1530 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -23,6 +23,7 @@ import Hetzner from "./pages/Hetzner"; import GameServers from "./pages/GameServers"; import Media from "./pages/Media"; import Downloads from "./pages/Downloads"; +import HetznerRobot from "./pages/HetznerRobot"; import AdguardHome from "./pages/AdguardHome"; import TechnitiumDns from "./pages/TechnitiumDns"; import Grafana from "./pages/Grafana"; @@ -187,6 +188,7 @@ function Shelled({ user }: { user: CurrentUser }) { } /> } /> } /> + } /> } /> } /> } /> diff --git a/web/src/api/client.ts b/web/src/api/client.ts index 58db786..6110c89 100644 --- a/web/src/api/client.ts +++ b/web/src/api/client.ts @@ -1564,6 +1564,41 @@ export interface DownloadItem { message: string | null; } +/** One Hetzner Robot account (an integration of type hetznerrobot), as the dedicated servers page shows it. */ +export interface RobotAccount { + id: number; + name: string; + enabled: boolean; + status: { at: string; ok: boolean; error: string | null } | null; + fresh: boolean; + state: { + servers: { + number: number; + name: string; + ip: string | null; + ipv6: string | null; + product: string | null; + dc: string | null; + traffic: string | null; + status: string; + cancelled: boolean; + paidUntil: string | null; + /** Null when it could not be asked. */ + rescue: boolean | null; + rescueSince: string | null; + notReadySince: string | null; + }[]; + /** Null when they could not be read. */ + storageBoxes: { id: number; name: string; login: string | null; product: string | null; location: string | null; cancelled: boolean; locked: boolean; paidUntil: string | null; linkedServer: number | null }[] | null; + skippedDetail: number; + updatedAt: string; + /** Calendar days to the end of each cancelled server (by number) and storage box (by id): 0 on the day it ends, negative after. */ + serverDays: Record; + boxDays: Record; + } | null; + problems: { key: string; message: string; severity: "warning" | "critical" }[]; +} + /** One qBittorrent or SABnzbd (an integration of that type), as the download clients page shows it. */ export interface DownloadClient { id: number; @@ -2981,7 +3016,7 @@ export interface ManualTaskInput { enabled?: boolean; } -export type IntegrationType = "proxmox" | "synology" | "semaphore" | "tailscale" | "gitea" | "dockhand" | "uptimekuma" | "phpipam" | "pbs" | "osticket" | "unifi" | "npm" | "homeassistant" | "ups" | "jellyfin" | "authentik" | "prometheus" | "immich" | "paperless" | "nextcloud" | "netbox" | "n8n" | "hetzner" | "speedtest" | "fragnet" | "sonarr" | "radarr" | "prowlarr" | "adguard" | "technitium" | "grafana" | "lidarr" | "readarr" | "qbittorrent" | "sabnzbd"; +export type IntegrationType = "proxmox" | "synology" | "semaphore" | "tailscale" | "gitea" | "dockhand" | "uptimekuma" | "phpipam" | "pbs" | "osticket" | "unifi" | "npm" | "homeassistant" | "ups" | "jellyfin" | "authentik" | "prometheus" | "immich" | "paperless" | "nextcloud" | "netbox" | "n8n" | "hetzner" | "speedtest" | "fragnet" | "sonarr" | "radarr" | "prowlarr" | "adguard" | "technitium" | "grafana" | "lidarr" | "readarr" | "qbittorrent" | "sabnzbd" | "hetznerrobot"; export interface IntegrationField { key: string; @@ -3603,6 +3638,9 @@ export const api = { downloads: { list: () => request<{ clients: DownloadClient[] }>("/api/downloads"), }, + hetznerRobot: { + list: () => request<{ accounts: RobotAccount[] }>("/api/hetzner-robot"), + }, fragnet: { list: () => request<{ accounts: FragnetAccount[] }>("/api/fragnet"), power: (integrationId: number, serverId: string, signal: FragnetSignal) => request(`/api/fragnet/${integrationId}/servers/${serverId}/power`, { method: "POST", body: JSON.stringify({ signal }) }), diff --git a/web/src/components/WallView.tsx b/web/src/components/WallView.tsx index f3fdbed..456927d 100644 --- a/web/src/components/WallView.tsx +++ b/web/src/components/WallView.tsx @@ -41,6 +41,7 @@ const TYPE_LABELS: Record = { readarr: "Readarr", qbittorrent: "qBittorrent", sabnzbd: "SABnzbd", + hetznerrobot: "Hetzner Robot", }; export type WallLevel = "critical" | "warning" | "ok" | "unsure"; diff --git a/web/src/layout/nav.tsx b/web/src/layout/nav.tsx index 140f51e..517a49b 100644 --- a/web/src/layout/nav.tsx +++ b/web/src/layout/nav.tsx @@ -44,6 +44,7 @@ import { IconBooks, IconDownload, IconCloudDownload, + IconCpu, IconBox, IconHeartbeat, IconGitCommit, @@ -102,6 +103,7 @@ export const NAV: NavEntry[] = [ { to: "/synology", label: "Synology", icon: }, { to: "/docker", label: "Docker", icon: }, { to: "/hetzner", label: "Hetzner Cloud", icon: }, + { to: "/hetzner-robot", label: "Hetzner Robot", icon: }, { to: "/game-servers", label: "Game servers", icon: }, { to: "/tailscale", label: "Tailscale", icon: }, ], diff --git a/web/src/pages/HetznerRobot.tsx b/web/src/pages/HetznerRobot.tsx new file mode 100644 index 0000000..01d7afb --- /dev/null +++ b/web/src/pages/HetznerRobot.tsx @@ -0,0 +1,221 @@ +import { useEffect, useState } from "react"; +import { Link } from "react-router-dom"; +import { api, type RobotAccount } from "../api/client"; +import EmptyState from "../components/EmptyState"; +import TimeAgo from "../components/TimeAgo"; +import { BlockSkeleton } from "../components/Skeleton"; +import { ErrorNotice } from "../components/Notice"; +import { readableError } from "../utils/errors"; + +function Badge({ a }: { a: RobotAccount }) { + if (!a.enabled) return Off; + if (!a.state) return Not read yet; + if (!a.fresh) return Can’t be read; + if (a.problems.some((x) => x.severity === "critical")) return Needs a look; + if (a.problems.length > 0) return Needs a look; + return In order; +} + +function Tile({ label, value, sub, warn }: { label: string; value: string; sub?: string | null; warn?: boolean }) { + return ( +
+
+
+
{label}
+
{value}
+ {sub &&
{sub}
} +
+
+
+ ); +} + +/** "Paid until 2026-12-01", or, for one that is cancelled, when it ends and how long that is. */ +function Until({ date, cancelled, days }: { date: string | null; cancelled: boolean; days: number | null | undefined }) { + if (!date) return —; + if (!cancelled) return paid until {date}; + const urgent = days !== null && days !== undefined && days <= 7; + const soon = days !== null && days !== undefined && days <= 30; + return ( + <> + cancelled +
+ ends {date} + {days !== null && days !== undefined ? (days < 0 ? " — has ended" : days === 0 ? " — today" : ` — ${days} day${days === 1 ? "" : "s"} left`) : ""} +
+ + ); +} + +function Card({ a }: { a: RobotAccount }) { + const s = a.state; + const rescue = s?.servers.filter((v) => v.rescue === true).length ?? 0; + const cancelled = (s?.servers.filter((v) => v.cancelled).length ?? 0) + (s?.storageBoxes?.filter((b) => b.cancelled).length ?? 0); + return ( +
+
+

+ {a.name} +

+
{a.status ? <>read : "not read yet"}
+
+
+ {a.status && !a.status.ok &&
The last attempt to read it failed: {a.status.error ?? "no answer"}.
} + {a.problems.length > 0 && ( +
    + {a.problems.map((x) => ( +
  • + {x.message} +
  • + ))} +
+ )} + {s && ( + <> +
+ + 0 ? "the next boot is into it" : "none"} warn={rescue > 0} /> + 0 ? "servers and storage boxes shutting down" : "nothing shutting down"} warn={cancelled > 0} /> + b.locked) ? "one is locked" : null} warn={!!s.storageBoxes?.some((b) => b.locked)} /> +
+ {s.skippedDetail > 0 &&
{s.skippedDetail} server{s.skippedDetail === 1 ? "" : "s"} beyond the first 25 were not asked about their rescue system (Hetzner allows 200 requests an hour).
} + {s.servers.length > 0 && ( +
+ + + + + + + + + + + + + + {s.servers.map((v) => ( + + + + + + + + + + ))} + +
ServerProductAddressTrafficStatusRescuePaid
+ {v.name} +
#{v.number}
+
+ {v.product ?? "—"} + {v.dc &&
{v.dc}
} +
+ {v.ip ? {v.ip} : "—"} + {v.ipv6 && ( +
+ {v.ipv6} +
+ )} +
{v.traffic ?? "—"}{v.status === "ready" ? ready : {v.status}} + {v.rescue === null ? ( + — + ) : v.rescue ? ( + <> + on + {v.rescueSince && ( +
+ since +
+ )} + + ) : ( + off + )} +
+ +
+
+ )} + {s.storageBoxes && s.storageBoxes.length > 0 && ( + <> +

Storage boxes

+
+ + + + + + + + + + + + + {s.storageBoxes.map((b) => ( + + + + + + + + + ))} + +
Storage boxProductLocationLinked toStatePaid
+ {b.name} +
{b.login ?? `#${b.id}`}
+
{b.product ?? "—"}{b.location ?? "—"}{b.linkedServer !== null ? (s.servers.find((v) => v.number === b.linkedServer)?.name ?? `server ${b.linkedServer}`) : "—"}{b.locked ? locked : open} + +
+
+ + )} + + )} +
+
+ ); +} + +/** Hetzner Robot: the account's dedicated servers (rescue system, cancellation) and storage boxes. */ +export default function HetznerRobot() { + const [data, setData] = useState(null); + const [error, setError] = useState(null); + useEffect(() => { + const load = () => + api.hetznerRobot + .list() + .then((r) => { + setData(r.accounts); + setError(null); + }) + .catch((err) => setError(readableError(err))); + void load(); + const t = setInterval(load, 60_000); + return () => clearInterval(t); + }, []); + return ( + <> +

Hetzner Robot

+

+ Dedicated servers and storage boxes at Hetzner (Robot — the cloud servers are on Hetzner Cloud), read every fifteen minutes (see Integrations) — nothing is reset, ordered or cancelled.{" "} + A server or storage box that is cancelled and about to shut down, a locked storage box, a rescue system left on and a server stuck being set up are alerts — see Alerts. +

+ + {!data && !error && } + {data && data.length === 0 && ( +
+
+ +
+
+ )} + {data?.map((a) => )} + + ); +} diff --git a/web/src/utils/alertKinds.ts b/web/src/utils/alertKinds.ts index 4ad2180..843847c 100644 --- a/web/src/utils/alertKinds.ts +++ b/web/src/utils/alertKinds.ts @@ -29,6 +29,11 @@ const KIND_WORDS: Record = { "readarr-health": "Readarr reporting a problem", "readarr-queue": "stuck downloads in Readarr", "prowlarr-health": "Prowlarr reporting a problem", + "hetznerrobot-ending": "a Hetzner dedicated server about to shut down", + "hetznerrobot-rescue": "a Hetzner rescue system left on", + "hetznerrobot-setup": "a Hetzner dedicated server stuck being set up", + "hetznerrobot-boxlocked": "a locked Hetzner storage box", + "hetznerrobot-boxending": "a Hetzner storage box about to shut down", "qbittorrent-stuck": "stuck torrents in qBittorrent", "qbittorrent-connection": "qBittorrent with no connection", "qbittorrent-disk": "a qBittorrent download disk filling up", diff --git a/web/src/utils/integrationTypes.ts b/web/src/utils/integrationTypes.ts index b19a499..24283b8 100644 --- a/web/src/utils/integrationTypes.ts +++ b/web/src/utils/integrationTypes.ts @@ -37,6 +37,7 @@ export const TYPE_LABELS: Record = { readarr: "Readarr", qbittorrent: "qBittorrent", sabnzbd: "SABnzbd", + hetznerrobot: "Hetzner Robot", }; /** The page each kind of integration gets once it is connected. */ @@ -76,11 +77,12 @@ export const TYPE_PAGES: Record = { readarr: "/media", qbittorrent: "/downloads", sabnzbd: "/downloads", + hetznerrobot: "/hetzner-robot", }; /** The kinds of integration grouped the way the sidebar groups their pages, in the same order. */ export const TYPE_GROUPS: { id: string; label: string; types: IntegrationType[] }[] = [ - { id: "infrastructure", label: "Infrastructure", types: ["proxmox", "synology", "dockhand", "hetzner", "fragnet", "tailscale"] }, + { id: "infrastructure", label: "Infrastructure", types: ["proxmox", "synology", "dockhand", "hetzner", "hetznerrobot", "fragnet", "tailscale"] }, { id: "apps", label: "Apps", types: ["homeassistant", "jellyfin", "sonarr", "radarr", "lidarr", "readarr", "prowlarr", "qbittorrent", "sabnzbd", "immich", "paperless", "nextcloud", "authentik"] }, { id: "backups", label: "Backups", types: ["pbs"] }, { id: "network", label: "Network", types: ["unifi", "npm", "phpipam", "netbox", "adguard", "technitium"] }, @@ -89,7 +91,7 @@ export const TYPE_GROUPS: { id: string; label: string; types: IntegrationType[] ]; /** The kinds whose reader can be inspected (Settings → Integrations → Check what can be read): the ones that read through the shared HTTP helper and have a reader to run. */ -export const INSPECTABLE: IntegrationType[] = ["authentik", "immich", "jellyfin", "netbox", "nextcloud", "paperless", "prometheus", "hetzner", "speedtest", "fragnet", "sonarr", "radarr", "prowlarr", "lidarr", "readarr", "qbittorrent", "sabnzbd", "adguard", "technitium", "grafana"]; +export const INSPECTABLE: IntegrationType[] = ["authentik", "immich", "jellyfin", "netbox", "nextcloud", "paperless", "prometheus", "hetzner", "speedtest", "fragnet", "sonarr", "radarr", "prowlarr", "lidarr", "readarr", "qbittorrent", "sabnzbd", "hetznerrobot", "adguard", "technitium", "grafana"]; /** The group a kind belongs to; a kind nobody has placed yet falls in "Other" rather than vanishing. */ export function groupOfType(type: IntegrationType): { id: string; label: string } {