fix sql migrations
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-01-14 15:08:59 +11:00
parent cfc4efee0e
commit 98899e306f
2 changed files with 79 additions and 1 deletions

View File

@@ -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.hourly_snapshot_max_age_days` (default: 60)
- `settings.daily_snapshot_max_age_months` (default: 12) - `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

View File

@@ -1,6 +1,45 @@
-- +goose Up -- +goose Up
-- +goose StatementBegin -- +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 StatementEnd
-- +goose Down -- +goose Down