Files
huntingclubroster/bin/check-health.php
T

10 lines
679 B
PHP
Raw Normal View History

<?php
if(PHP_SAPI!=='cli'){http_response_code(404);exit;}
require __DIR__.'/../classes/Base.php';
try{
$db=(new Base())->connect();$db->query('SELECT 1')->fetchColumn();
if(!(new RosterService())->ready())throw new RuntimeException('Required schema is missing.');
foreach(['user_email_verified_at'] as $column){$columns=$db->query('SHOW COLUMNS FROM users')->fetchAll(PDO::FETCH_COLUMN);if(!in_array($column,$columns,true))throw new RuntimeException('Account schema is missing.');}
echo "Database and required application schema are available.\n";
}catch(Throwable $e){fwrite(STDERR,"Health check failed. Review the protected server logs.\n");error_log((string)$e);exit(1);}