Initial
This commit is contained in:
61
server/db.js
61
server/db.js
@@ -93,10 +93,60 @@ export function migrate() {
|
||||
credential_id TEXT REFERENCES credentials(id) ON DELETE SET NULL,
|
||||
tags TEXT NOT NULL DEFAULT '[]',
|
||||
notes TEXT,
|
||||
source_type TEXT NOT NULL DEFAULT 'manual',
|
||||
source_connection_id TEXT,
|
||||
source_ref TEXT,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS vcenter_connections (
|
||||
id TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
base_url TEXT NOT NULL,
|
||||
username TEXT NOT NULL,
|
||||
secret_cipher TEXT NOT NULL,
|
||||
secret_iv TEXT NOT NULL,
|
||||
secret_tag TEXT NOT NULL,
|
||||
api_mode TEXT NOT NULL DEFAULT 'auto',
|
||||
request_timeout_ms INTEGER NOT NULL DEFAULT 20000,
|
||||
allow_untrusted_tls INTEGER NOT NULL DEFAULT 0,
|
||||
enabled INTEGER NOT NULL DEFAULT 1,
|
||||
last_test_status TEXT,
|
||||
last_test_message TEXT,
|
||||
last_test_at TEXT,
|
||||
visibility TEXT NOT NULL DEFAULT 'shared',
|
||||
owner_user_id TEXT REFERENCES users(id) ON DELETE SET NULL,
|
||||
group_id TEXT REFERENCES groups(id) ON DELETE SET NULL,
|
||||
created_by TEXT REFERENCES users(id) ON DELETE SET NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS host_groups (
|
||||
id TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
mode TEXT NOT NULL DEFAULT 'manual',
|
||||
match_mode TEXT NOT NULL DEFAULT 'all',
|
||||
rules TEXT NOT NULL DEFAULT '[]',
|
||||
visibility TEXT NOT NULL DEFAULT 'shared',
|
||||
owner_user_id TEXT REFERENCES users(id) ON DELETE SET NULL,
|
||||
group_id TEXT REFERENCES groups(id) ON DELETE SET NULL,
|
||||
created_by TEXT REFERENCES users(id) ON DELETE SET NULL,
|
||||
last_synced_at TEXT,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS host_group_members (
|
||||
host_group_id TEXT NOT NULL REFERENCES host_groups(id) ON DELETE CASCADE,
|
||||
host_id TEXT NOT NULL REFERENCES hosts(id) ON DELETE CASCADE,
|
||||
source TEXT NOT NULL DEFAULT 'manual',
|
||||
created_at TEXT NOT NULL,
|
||||
PRIMARY KEY (host_group_id, host_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS folders (
|
||||
id TEXT PRIMARY KEY,
|
||||
parent_id TEXT REFERENCES folders(id) ON DELETE CASCADE,
|
||||
@@ -384,6 +434,12 @@ export function migrate() {
|
||||
PRIMARY KEY (runplan_id, host_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS runplan_host_groups (
|
||||
runplan_id TEXT NOT NULL REFERENCES runplans(id) ON DELETE CASCADE,
|
||||
host_group_id TEXT NOT NULL REFERENCES host_groups(id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (runplan_id, host_group_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS jobs (
|
||||
id TEXT PRIMARY KEY,
|
||||
runplan_id TEXT REFERENCES runplans(id) ON DELETE SET NULL,
|
||||
@@ -450,6 +506,11 @@ export function migrate() {
|
||||
ensureColumn('hosts', 'visibility', "TEXT NOT NULL DEFAULT 'shared'");
|
||||
ensureColumn('hosts', 'owner_user_id', 'TEXT REFERENCES users(id) ON DELETE SET NULL');
|
||||
ensureColumn('hosts', 'group_id', 'TEXT REFERENCES groups(id) ON DELETE SET NULL');
|
||||
// Host provenance is hidden from normal manual edit forms but used by
|
||||
// automation gates such as vCenter power-state checks before execution.
|
||||
ensureColumn('hosts', 'source_type', "TEXT NOT NULL DEFAULT 'manual'");
|
||||
ensureColumn('hosts', 'source_connection_id', 'TEXT');
|
||||
ensureColumn('hosts', 'source_ref', 'TEXT');
|
||||
// Tenant write-back is opt-in per Graph connection. Default 0 so existing
|
||||
// read-only connections can never be used to change a tenant by accident.
|
||||
ensureColumn('graph_connections', 'allow_write', 'INTEGER NOT NULL DEFAULT 0');
|
||||
|
||||
Reference in New Issue
Block a user