This commit is contained in:
2026-09-16 13:53:54 +02:00
parent 0b5ca54db9
commit d4e4b69e02
6 changed files with 97 additions and 68 deletions
+8 -1
View File
@@ -126,8 +126,14 @@ function ensure_tables_exist(PDO $pdo): void {
if ($tablesChecked) return;
$tablesChecked = true;
$schemaFile = file_exists(__DIR__ . '/schema.sql') ? (__DIR__ . '/schema.sql') : (__DIR__ . '/../schema.sql');
$lockFile = sys_get_temp_dir() . '/fociz_schema_' . md5(__DIR__) . '.lock';
if (file_exists($lockFile) && file_exists($schemaFile) && filemtime($lockFile) >= filemtime($schemaFile)) {
return;
}
try {
$schemaFile = file_exists(__DIR__ . '/schema.sql') ? (__DIR__ . '/schema.sql') : (__DIR__ . '/../schema.sql');
if (file_exists($schemaFile)) {
$sql = file_get_contents($schemaFile);
$statements = array_filter(array_map('trim', explode(';', $sql)));
@@ -300,6 +306,7 @@ function ensure_tables_exist(PDO $pdo): void {
} catch (Throwable $e) {
// Stil negeren indien system_settings tabel nog niet bestaat
}
@touch($lockFile);
} catch (Throwable $e) {
error_log("Fout bij controleren tabellen: " . $e->getMessage());
}