Files
Termix/plugins/proxmox/migrations/sqlite/0001_adopt_proxmox_stats.sql
T

28 lines
1.2 KiB
SQL

-- proxmox 0001: adopt_proxmox_stats
-- Generated by termix-plugin migrations. Review before committing.
CREATE TABLE IF NOT EXISTS "proxmox_node_history" (
"id" integer PRIMARY KEY AUTOINCREMENT,
"host_id" integer NOT NULL,
"ts" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
"cpu_percent" real,
"mem_percent" real,
"disk_percent" real,
"net_rx_bytes" integer,
"net_tx_bytes" integer,
FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE
);
ALTER TABLE "proxmox_node_history" RENAME TO "p_proxmox_node_history";
CREATE TABLE IF NOT EXISTS "proxmox_stats_preferences" (
"id" integer PRIMARY KEY AUTOINCREMENT,
"user_id" text NOT NULL,
"host_id" integer NOT NULL,
"layout" text NOT NULL,
"created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE,
FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE
);
CREATE UNIQUE INDEX IF NOT EXISTS "idx_proxmox_stats_prefs_user_host" ON "proxmox_stats_preferences" ("user_id", "host_id");
ALTER TABLE "proxmox_stats_preferences" RENAME TO "p_proxmox_stats_preferences";