fix(cluster): auto-ensure blf_expiry and peer_port columns exist in ClusterManager constructor

This commit is contained in:
sorcier committed 2026-11-06 01:21:03 +01:00
1 parent f14185d597
commit 767fea46b7
1 file changed
+14
+14
View File
@@ -21,6 +21,20 @@ class ClusterManager
public function __construct(?PDO $db = null) public function __construct(?PDO $db = null)
{ {
$this->db = $db ?? Database::getConnection(); $this->db = $db ?? Database::getConnection();
$this->ensureColumns();
}
private function ensureColumns(): void
{
try {
$cols = $this->db->query("PRAGMA table_info(cluster_settings)")->fetchAll(PDO::FETCH_COLUMN, 1);
if (!in_array('blf_expiry', $cols, true)) {
$this->db->exec("ALTER TABLE cluster_settings ADD COLUMN blf_expiry INTEGER NOT NULL DEFAULT 120");
}
if (!in_array('peer_port', $cols, true)) {
$this->db->exec("ALTER TABLE cluster_settings ADD COLUMN peer_port INTEGER NOT NULL DEFAULT 8443");
}
} catch (\Throwable $e) {}
} }
/** /**