2026-09-01 19:22:48 +02:00
|
|
|
<?php
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
if (PHP_SAPI !== 'cli') {
|
|
|
|
|
http_response_code(404);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
require_once __DIR__ . '/../config/bootstrap.php';
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$schemaPath = __DIR__ . '/../database/schema.sql';
|
|
|
|
|
if (!is_readable($schemaPath)) throw new RuntimeException('database/schema.sql is missing or unreadable');
|
2026-09-01 19:26:10 +02:00
|
|
|
$schema = file_get_contents($schemaPath);
|
|
|
|
|
if ($schema === false || trim($schema) === '') throw new RuntimeException('database/schema.sql could not be read');
|
|
|
|
|
db()->exec($schema);
|
2026-09-01 19:22:48 +02:00
|
|
|
ensure_initial_administrator();
|
|
|
|
|
fwrite(STDOUT, "Database schema installed and initial Administrator verified.\n");
|
|
|
|
|
} catch (Throwable $exception) {
|
|
|
|
|
fwrite(STDERR, "Installation failed: {$exception->getMessage()}\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|