11 lines
1.4 KiB
PHP
11 lines
1.4 KiB
PHP
<?php
|
|
ini_set('zend.exception_ignore_args','1');set_exception_handler(function(Throwable $e){fwrite(STDERR,'Read-only status stopped: '.$e::class.PHP_EOL);exit(1);});
|
|
$root=dirname(__DIR__,2);require $root.'/vendor/autoload.php';$app=require $root.'/bootstrap/app.php';
|
|
(new Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables)->bootstrap($app);(new Illuminate\Foundation\Bootstrap\LoadConfiguration)->bootstrap($app);
|
|
$c=config('database.connections.'.config('database.default'));
|
|
if($c['driver']!=='pgsql'||$c['database']!=='investemoz'||(int)$c['port']!==5432||!in_array($c['host'],['127.0.0.1','localhost'])||!empty($c['url']))throw new RuntimeException('Destination guard');
|
|
$db=new PDO('pgsql:host='.$c['host'].';port=5432;dbname=investemoz',$c['username'],$c['password'],[PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION]);$db->exec('BEGIN READ ONLY');
|
|
try{echo json_encode(['read_only'=>true,'ledger'=>(int)$db->query("SELECT count(*) FROM migrations WHERE migration='2026_10_16_130000_add_investment_zone_editorial_draft'")->fetchColumn(),
|
|
'column'=>(int)$db->query("SELECT count(*) FROM information_schema.columns WHERE table_schema='public' AND table_name='investment_zones' AND column_name='editorial_draft'")->fetchColumn(),
|
|
'installation_events'=>(int)$db->query("SELECT count(*) FROM audit_events WHERE source_system='investment-zone-profile-installation'")->fetchColumn()]).PHP_EOL;}finally{$db->exec('ROLLBACK');}
|