From 98899e306fdf90acbe77cf93047529f007cbe72a Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 14 Jan 2026 15:08:59 +1100 Subject: [PATCH] fix sql migrations --- README.md | 39 +++++++++++++++++++ db/migrations/20250116090000_drop_vmtype.sql | 41 +++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b8893df..9fc965d 100644 --- a/README.md +++ b/README.md @@ -62,3 +62,42 @@ Hourly and daily snapshot table retention can be configured in the settings file - `settings.hourly_snapshot_max_age_days` (default: 60) - `settings.daily_snapshot_max_age_months` (default: 12) + +#### Settings Reference +All configuration lives under the top-level `settings:` key in `vctp.yml`. + +General: +- `settings.log_level`: logging verbosity (e.g., `debug`, `info`, `warn`, `error`) +- `settings.log_output`: log format, `text` or `json` + +Database: +- `settings.database_driver`: `sqlite` or `postgres` +- `settings.database_url`: SQLite file path/DSN or PostgreSQL DSN + +HTTP/TLS: +- `settings.bind_ip`: IP address to bind the HTTP server +- `settings.bind_port`: TCP port to bind the HTTP server +- `settings.bind_disable_tls`: `true` to serve plain HTTP (no TLS) +- `settings.tls_cert_filename`: PEM certificate path (TLS mode) +- `settings.tls_key_filename`: PEM private key path (TLS mode) + +vCenter: +- `settings.vcenter_username`: vCenter username +- `settings.vcenter_password`: vCenter password (encrypted at startup) +- `settings.vcenter_insecure`: `true` to skip TLS verification +- `settings.vcenter_event_polling_seconds`: event polling interval (0 disables) +- `settings.vcenter_inventory_polling_seconds`: inventory polling interval (0 disables) +- `settings.vcenter_inventory_snapshot_seconds`: hourly snapshot cadence (seconds) +- `settings.vcenter_inventory_aggregate_seconds`: daily aggregation cadence (seconds) +- `settings.vcenter_addresses`: list of vCenter SDK URLs to monitor + +Snapshots: +- `settings.hourly_snapshot_concurrency`: max concurrent vCenter snapshots (0 = unlimited) +- `settings.hourly_snapshot_max_age_days`: retention for hourly tables +- `settings.daily_snapshot_max_age_months`: retention for daily tables +- `settings.snapshot_cleanup_cron`: cron expression for cleanup job + +Filters/chargeback: +- `settings.tenants_to_filter`: list of tenant name patterns to exclude +- `settings.node_charge_clusters`: list of cluster name patterns for node chargeback +- `settings.srm_activeactive_vms`: list of SRM Active/Active VM name patterns diff --git a/db/migrations/20250116090000_drop_vmtype.sql b/db/migrations/20250116090000_drop_vmtype.sql index 165dc59..0d5ceba 100644 --- a/db/migrations/20250116090000_drop_vmtype.sql +++ b/db/migrations/20250116090000_drop_vmtype.sql @@ -1,6 +1,45 @@ -- +goose Up -- +goose StatementBegin -ALTER TABLE "Inventory" DROP COLUMN "VmType"; +PRAGMA foreign_keys=OFF; + +ALTER TABLE "Inventory" RENAME TO "Inventory_old"; + +CREATE TABLE IF NOT EXISTS "Inventory" ( + "Iid" INTEGER PRIMARY KEY AUTOINCREMENT, + "Name" TEXT NOT NULL, + "Vcenter" TEXT NOT NULL, + "VmId" TEXT, + "EventKey" TEXT, + "CloudId" TEXT, + "CreationTime" INTEGER, + "DeletionTime" INTEGER, + "ResourcePool" TEXT, + "Datacenter" TEXT, + "Cluster" TEXT, + "Folder" TEXT, + "ProvisionedDisk" REAL, + "InitialVcpus" INTEGER, + "InitialRam" INTEGER, + "IsTemplate" TEXT NOT NULL DEFAULT "FALSE", + "PoweredOn" TEXT NOT NULL DEFAULT "FALSE", + "SrmPlaceholder" TEXT NOT NULL DEFAULT "FALSE", + "VmUuid" TEXT +); + +INSERT INTO "Inventory" ( + "Iid", "Name", "Vcenter", "VmId", "EventKey", "CloudId", "CreationTime", "DeletionTime", + "ResourcePool", "Datacenter", "Cluster", "Folder", "ProvisionedDisk", "InitialVcpus", + "InitialRam", "IsTemplate", "PoweredOn", "SrmPlaceholder", "VmUuid" +) +SELECT + "Iid", "Name", "Vcenter", "VmId", "EventKey", "CloudId", "CreationTime", "DeletionTime", + "ResourcePool", "Datacenter", "Cluster", "Folder", "ProvisionedDisk", "InitialVcpus", + "InitialRam", "IsTemplate", "PoweredOn", "SrmPlaceholder", "VmUuid" +FROM "Inventory_old"; + +DROP TABLE "Inventory_old"; + +PRAGMA foreign_keys=ON; -- +goose StatementEnd -- +goose Down