Initial
This commit is contained in:
63
server/db.js
63
server/db.js
@@ -442,6 +442,32 @@ export function migrate() {
|
||||
PRIMARY KEY (runplan_id, host_group_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS runplan_schedules (
|
||||
id TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
runplan_id TEXT NOT NULL REFERENCES runplans(id) ON DELETE CASCADE,
|
||||
enabled INTEGER NOT NULL DEFAULT 1,
|
||||
schedule_type TEXT NOT NULL DEFAULT 'once',
|
||||
start_at TEXT NOT NULL,
|
||||
end_at TEXT,
|
||||
time_of_day TEXT,
|
||||
interval_value INTEGER,
|
||||
interval_unit TEXT,
|
||||
days_of_week TEXT NOT NULL DEFAULT '[]',
|
||||
day_of_month INTEGER,
|
||||
month_of_year INTEGER,
|
||||
next_run_at TEXT,
|
||||
last_run_at TEXT,
|
||||
last_job_id TEXT REFERENCES jobs(id) ON DELETE SET NULL,
|
||||
visibility TEXT NOT NULL DEFAULT 'personal',
|
||||
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 jobs (
|
||||
id TEXT PRIMARY KEY,
|
||||
runplan_id TEXT REFERENCES runplans(id) ON DELETE SET NULL,
|
||||
@@ -472,6 +498,32 @@ export function migrate() {
|
||||
created_at TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS job_outputs (
|
||||
id TEXT PRIMARY KEY,
|
||||
job_id TEXT NOT NULL REFERENCES jobs(id) ON DELETE CASCADE,
|
||||
kind TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
mime_type TEXT NOT NULL,
|
||||
storage_path TEXT NOT NULL,
|
||||
size_bytes INTEGER NOT NULL DEFAULT 0,
|
||||
checksum TEXT NOT NULL,
|
||||
metadata_json TEXT NOT NULL DEFAULT '{}',
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL,
|
||||
UNIQUE(job_id, kind)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS runplan_schedule_runs (
|
||||
id TEXT PRIMARY KEY,
|
||||
schedule_id TEXT NOT NULL REFERENCES runplan_schedules(id) ON DELETE CASCADE,
|
||||
runplan_id TEXT REFERENCES runplans(id) ON DELETE SET NULL,
|
||||
job_id TEXT REFERENCES jobs(id) ON DELETE SET NULL,
|
||||
planned_for TEXT NOT NULL,
|
||||
status TEXT NOT NULL,
|
||||
message TEXT,
|
||||
created_at TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS system_job_actions (
|
||||
id TEXT PRIMARY KEY,
|
||||
job_id TEXT,
|
||||
@@ -531,6 +583,7 @@ export function migrate() {
|
||||
ensureColumn('vcenter_connections', 'target_type', "TEXT NOT NULL DEFAULT 'vcenter'");
|
||||
ensureColumn('vcenter_connections', 'credential_id', 'TEXT REFERENCES credentials(id) ON DELETE SET NULL');
|
||||
ensureColumn('system_job_actions', 'metadata_json', "TEXT NOT NULL DEFAULT '{}'");
|
||||
ensureColumn('job_outputs', 'metadata_json', "TEXT NOT NULL DEFAULT '{}'");
|
||||
// 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');
|
||||
@@ -601,9 +654,17 @@ export function seed() {
|
||||
VALUES (?, ?, 'default', ?)
|
||||
ON CONFLICT(key) DO NOTHING
|
||||
`);
|
||||
const releaseEnvSource = db.prepare(`
|
||||
UPDATE settings
|
||||
SET value = ?, source = 'default', updated_at = ?
|
||||
WHERE key = ? AND source = 'env'
|
||||
`);
|
||||
for (const def of settingDefinitions()) {
|
||||
if (def.pinned) pinned.run(def.key, def.value, now());
|
||||
else defaulted.run(def.key, def.value, now());
|
||||
else {
|
||||
defaulted.run(def.key, def.value, now());
|
||||
releaseEnvSource.run(def.value, now(), def.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user