Align project devices with circuit model
This commit is contained in:
@@ -18,14 +18,35 @@ const rows = db
|
||||
|
||||
const existing = new Set(rows.map((row) => row.name));
|
||||
const missing = requiredTables.filter((name) => !existing.has(name));
|
||||
const requiredProjectDeviceColumns = [
|
||||
"phase_type",
|
||||
"connection_kind",
|
||||
"cost_group",
|
||||
"power_per_unit",
|
||||
"simultaneity_factor",
|
||||
"cos_phi",
|
||||
"remark",
|
||||
];
|
||||
const projectDeviceColumns = new Set(
|
||||
db.prepare("PRAGMA table_info(project_devices)").all().map((column) => column.name)
|
||||
);
|
||||
const missingProjectDeviceColumns = requiredProjectDeviceColumns.filter(
|
||||
(name) => !projectDeviceColumns.has(name)
|
||||
);
|
||||
|
||||
console.log("Database:", dbPath);
|
||||
console.log("Required tables:", requiredTables.join(", "));
|
||||
console.log("Existing tables:", [...existing].join(", ") || "(none)");
|
||||
console.log("Required project-device columns:", requiredProjectDeviceColumns.join(", "));
|
||||
|
||||
if (missing.length > 0) {
|
||||
console.error("Missing tables:", missing.join(", "));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (missingProjectDeviceColumns.length > 0) {
|
||||
console.error("Missing project-device columns:", missingProjectDeviceColumns.join(", "));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log("Circuit-first schema verification passed.");
|
||||
|
||||
Reference in New Issue
Block a user